mybatis integer data update, no effect

679 views Asked by At
public int createCountry(String countryCode) {
    // TODO Auto-generated method stub
    SqlSession session = null;
    boolean commit = false;

    int result = 0;

    //System.out.println("바보 :" + countryCode);
    try {
        session = dbutil.getSqlSession();
        result = session.update("board.updateIsCreate", countryCode);
    } finally {
        dbutil.closeSqlSession(session, commit);
    }
    System.out.println("count" + result);

    return result;
}

Here's my DapIml.java

<update id="updateIsCreate" parameterType="String">
    UPDATE country
    SET isCreated = '1'
</update>

and, This is my mapper.xml.

I already checked update's return value is correct, but it has no effect in my database. isCreated value is not changed to '1'. Any suggestion on how to achieve this? I will appreciate for your help.

1

There are 1 answers

0
정동구 On

Sorry, I didn't write commit code...

I modified my daoImplement code like this :

public int createCountry(CountryVo countryVo) {
    // TODO Auto-generated method stub
    SqlSession session = null;
    boolean commit = false;

    int result = 0;

    //System.out.println("바보 :" + countryCode);
    try {
        session = dbutil.getSqlSession();
        result = session.update("board.updateIsCreate", countryVo);
        commit = result > 0 ? true : false;
    } finally {
        dbutil.closeSqlSession(session, commit);
    }
    System.out.println("count" + result);

    return result;
}