Search code examples
mybatisibatis

MyBatis delete isn't working with multiple conditions


I am relatively new to MyBatis. If I use only one condition like below, I don't have any issues at all.

final String DELETE = "Delete from request where author=#{author}"; // Working

final String DELETE = "Delete from request where refid=#{referenceId}"; // working

But if I give two conditions for delete, rows are not getting deleted at all.

final String DELETE = "Delete from request where refid=#{referenceId} and author=#{author}"; // Not working.

And my interface looks like this,

@Delete(DELETE) public void delete(Request request);

Could someone help me to understand what mistake I am doing in this? I am using MyBatis 3.1.1 and MySQL

Thanks,


Solution

  • I don't know, after changing the return type in the interface to Integer, things started working fine.

    But as per the document, http://mybatis.github.io/mybatis-3/java-api.html, return value just indicates the number of rows affected.

    @Delete(DELETE) public Integer delete(InviteRequest request); // This made stuff working with two conditions.