Grails 排序不工作
我有一个包含 order by 子句的 Grails 查询,但是当结果返回时,它们并不是按该字段排序的。如果我在数据库中运行相同的查询,它将正常工作。
String sql = "select child From Affiliation a join a.childrenPhases cp join cp.affiliation child where a = :affiliation and child.type = '${TYPE_CONFERENCE}' order by a.name asc"
return executeQuery(sql, [affiliation: this])
a
中的 name
是一个休眠公式字段。会不会跟这个有关系呢?谢谢。
I have a Grails query that has an order by clause, but when the results come back they are not ordered by that field. If I run the same query in the database it works correctly.
String sql = "select child From Affiliation a join a.childrenPhases cp join cp.affiliation child where a = :affiliation and child.type = '${TYPE_CONFERENCE}' order by a.name asc"
return executeQuery(sql, [affiliation: this])
name
off of a
is a hibernate formula field. Could this have to do with it? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决此类问题的最佳方法是转储 hibernate 生成的 SQL。将以下内容添加到您的 DataSource.groovy:
The best way to troubleshoot a problem like this is to dump the SQL generated by hibernate. Add the following to your DataSource.groovy: