I got an error with a dynamic query. This is the query I have:
<dynamic>
select * from Tbl_Member
WHERE
<isNotNull property="FirstName">
FIRST_NAME = #lastName#
</isNotNull>
<isNotNull prepend="and" property="lastName">
LAST_NAME = #lastName#
</isNotNull>
<isNotNull prepend="and" property="">
</isNotNull>
.
.
.
.
</dynamic>
If the property is FirstNamenot null, the request works. But if the property is null and the other left property is LastNamenot null, I get an SQL error.
Since in this condition the SQL statement is as follows:
select * from Tbl_Member WHERE AND LAST_NAME = ? ...
How to remove the first added ANDif the first property becomesNull
PS:
I also tried removeFirstPrepend="true"
<isNotNull prepend="and" property="lastName" removeFirstPrepend="true">
LAST_NAME = #lastName#
</isNotNull>
But, unfortunately, it does not work either.
source
share