gpt4 book ai didi

mybatis - 动态排序类型在 mybatis 中不起作用

转载 作者:行者123 更新时间:2023-12-02 16:46:36 24 4
gpt4 key购买 nike

我无法在 mybatis 中使用动态排序类型创建 SQL,如下例

<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>

sortType 包含一个值 {DESC, ASC},当我从我的 dao 调用此 SQL 时,出现以下错误

原因:java.sql.SQLSyntaxErrorException:ORA-00933:SQL 命令未正确结束

有什么想法吗?

最佳答案

尝试${sortType}。如需直接替换,请使用 ${}。

关于mybatis - 动态排序类型在 mybatis 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13860056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com