SQL Server Delete query in MyBatis is not deleting anything

vcirk6k6  于 2023-04-28  发布在  其他
关注(0)|答案(1)|浏览(155)

I am relatively new in MyBatis. The select queries are working fine. But the delete queries and not working.

Mapper.xml

<delete id="deleteEntry" parameterType="java.util.HashMap"  >
        delete from table where  user_id = #{userId} and application_id = #{appId}
</delete>

Mapper.java

public interface Mapper {
    public Integer deleteEntry(@Param("userId") long userId, @Param("appId") long appId);
}

The DAO where I am calling the function looks like this.

SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();
        try{
            LOG.info("Records Deleted: "+sqlSession.getMapper(Mapper.class).deleteEntry(userId,appId));
        }
        finally {
            sqlSession.close();
        }

Now the result is Records Deleted: 1

However when i check the database, the row hasn't been deleted. I am using Sql Server.

Thank you for the help in advance. :)

zkure5ic

zkure5ic1#

Set auto-commit to true

SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession(true);

相关问题