简体   繁体   English

来自java spring的mybatis存储过程调用不起作用

[英]mybatis stored procedure call from java spring not working

I've been trying to call a stored procedure from java spring. 我一直在尝试从Java Spring调用存储过程。 Basically, this stored procedure would just insert the inputs from the user in this table. 基本上,此存储过程只是将来自用户的输入插入此表中。

enter image description here 在此处输入图片说明

This is my stored procedure : 这是我的存储过程:

create or replace PROCEDURE TEST_ADDFT
(
  FID IN RAW
, K IN VARCHAR2 
, V IN VARCHAR2 
) AS 

BEGIN
  INSERT INTO 
    ITCM_FT (FT_ID, KEY_ID, VALUE) 
  VALUES (FID, (SELECT KEY_ID FROM ITCM_KEY_VALUES 
  WHERE UPPER(KEY)=UPPER(K)),V);
END TEST_ADDFT;

So I've already set up everything (that I think) is needed. 因此,我已经设置了所有(我认为)必要的东西。 I've also placed the stored procedure in the database (I've used sqldeveloper for this). 我还将存储过程放置在数据库中(为此使用了sqldeveloper)。

Here's the service implementation : 这是服务实现:

@Transactional(readOnly = false, propagation = Propagation.REQUIRED,
        rollbackFor = Exception.class)
public void addTest(final List<TestCost> tcData)
        throws Exception {
    try {
        for (int i = 0; i < tcData.size(); i++) {
            tcData.get(i).setFtId(Utils.generateUUID());
            finalTestDao.addTest(tcData.get(i).getFtId(),
                    tcData.get(i).getKey(), tcData.get(i).getValue());
            System.out.println("-=-=-=-=-= added?");
        }
    } catch (Exception e) {
        Log.error("Add final test error", e);
    }
}

Here's my DAO : 这是我的DAO:

 void addTest(@Param("ftId") String ftId, @Param("key") String key,
        @Param("value") String value);

DAO.xml : DAO.xml:

<select id="addTest" parameterType="String" statementType="CALLABLE">
    { 
        CALL TEST_ADDFT (
            #{ftId, mode=IN, jdbcType=RAW},
            #{key, mode=IN, jdbcType=VARCHAR2},
            #{value, mode=IN, jdbcType=VARCHAR2}
        )
    }
</select>

I have already set up a POJO for the TestCost object and tested the procedure stated using sqldeveloper. 我已经为TestCost对象设置了POJO,并测试了使用sqldeveloper声明的过程。

What I do not understand is why the procedure is not being called. 我不明白的是为什么没有调用该过程。 No errors were being displayed in the console but line 10 from the service implementation (sysout statement) is not being executed. 控制台中未显示任何错误,但是未执行服务实现的第10行(sysout语句)。 Do you guys have any ideas regarding this? 你们对此有什么想法吗? Or maybe I did miss some configurations? 也许我确实错过了一些配置?

Thanks for the help! 谢谢您的帮助!

If you have declared tcData as final ... 如果您已将tcData声明为final ...

final List<TestCost> tcData

Then why are you updating it..? 那你为什么要更新它..?

tcData.get(i).setFtId(Utils.generateUUID());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM