简体   繁体   中英

mybatis stored procedure call from java spring not working

I've been trying to call a stored procedure from 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).

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 :

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

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.

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. 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 ...

final List<TestCost> tcData

Then why are you updating it..?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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