-
I have a simple POJO class which has two properties (as well as an integer id) which are strings: firstName and lastName The SQL statement in my mapper.xml looks like:
This only works if, in my mapper interface, I have @param annotations
Otherwise I have to use something like #{param1} etc. in my sql - which is less readable imho. Is there any way to replace the @param annotations with some XML in my mapping xml? Hope all that makes sense! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @phunni , If you compile your project with a compiler option By the way, if you pass the POJO as the sole parameter of the mapper method The following lines are from a test case. |
Beta Was this translation helpful? Give feedback.
Hello @phunni ,
If you compile your project with a compiler option
-parameters
, you can reference the parameters by their names in the method signature.There are some tests in this directory.
By the way, if you pass the POJO as the sole parameter of the mapper method
getByName()
, you can reference its properties directly in the statement (this does not require the aforementioned compiler option).The following lines are from a test case.
mybatis-3/src/test/java/org/apache/ibatis/submitted/basetest/Mapper.java
Line 22 in 38688d9
mybatis-3/src/test/resources/org/apache/ibatis/submitted/basetest/Mapper.xml
Line 30 in 38688d9