I am writing my fist MyBatis application and I stuck around @Select. I do not know what is the problem with my @Select definition, everything seems fine but I got a Parameter not found
exception.
I have followed the same pattern when I pass parameters to my my @Insert statement and it works without problem.
I use MyBatis 3.4.2.
This is my @Select:
@Select("SELECT * "
+ "FROM configuration "
+ "WHERE key_name = #{key} AND "
+ "(#{userId} IS NULL AND user_id IS NULL) OR user_id = #{userId} AND "
+ "status = 1")
Configuration findByKeyAndUserId(String key, Long userId);
The exception what I got:
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.binding.BindingException: Parameter 'key' not found. Available parameters are [arg1, arg0, param1, param2]
### Cause: org.apache.ibatis.binding.BindingException: Parameter 'key' not found. Available parameters are [arg1, arg0, param1, param2]