I couldn’t create SQL in mybatis using dynamic sort type as the following example
<select id="selectByNetworkId" parameterType="java.util.Map" resultMap="userResult">
select user_profile.user_profile_id, user_profile.first_name
from
user_profile user_profile
where
user_profile.network_id = #{network_id}
order by
user_profile.user_profile.first_name #{sortType}
</select>
the sortType holds one value of {DESC, ASC}, and I got the following error when calling this SQL from my dao
Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
any idea?
try ${sortType}. For direct substitution, use ${}.