MyBatis version
3.5.4
Database vendor and version
mysql 5.7.1
Test case or example project
#{entity.creator != null ? entity.creator.id : null }
find the class of ParameterExpression.class parse property of the expression to entity.creator != null ? entity.creator.id.
Steps to reproduce
Expected result
Actual result
Comment From: harawata
Hello, @likly .
#{} does not accept expression.
<bind /> helps in some cases.
<select ...>
<bind name="creatorId" value="entity.creator != null ? entity.creator.id : null" />
select * from creator where id = #{creatorId}
</select>
Please let us know the details if it didn't work.
Comment From: iimik
Hello, @likly .
#{}does not accept expression.<bind />helps in some cases.
<select ...> <bind name="creatorId" value="entity.creator != null ? entity.creator.id : null" /> select * from creator where id = #{creatorId} </select>Please let us know the details if it didn't work. Thanks, @harawata . It's worked when use
<bind/>tag. But it will be better if can use like this
<bind name="creator" value="entity.creator != null ? entity.creator.id : null">#{creator}</bind>
I have create a Pull Request to support this.
Comment From: harawata
For text substitution, you can use ${}, but it is usually not recommended.
Please see the FAQ.
Comment From: harawata
No response.