javasqlibatisibatis.net

How to determine if insertions have been completed in ibatis?


@Insert("insert into TABLE(c1, c2, c3) " +
        "values ( #{col1}, #{col2}, #{col3})")
Boolean save(Integer x, Integer y);

The returning Boolean would be True or False, determining if everything has been inserted properly


Solution

  • Anyway, you cannot do that. You need to use an int (or Integer) and compare it to 0.
    If result == 0, then no rows have been inserted.

    @Insert("insert into TABLE(c1, c2, c3) values (#{col1}, #{col2}, #{col3})")
    int save(final Integer x, final Integer y);
    

    Using MyBatis, you could have defined a custom ResultHandler<T>