Hibernate 使用复合键返回无效结果

发布于 2024-07-07 22:18:18 字数 354 浏览 7 评论 0原文

我得到了最奇怪的结果。 我有一堂带有复合键的课程。 如果我执行以下查询:

来自 LOVEJB l 按 l.canonicalId 订购 描述

我的结果未按我要求的“canonicalId”列排序。 相反,规范 id 结果如下:

823 823 822 823,,,

有人可以给我一些建议,告诉我应该如何破解这个问题吗? 我已经搞乱了 hashcodesequals,我尝试了一个新类等,但没有成功。

I'm getting the strangest results. I have a class with a composite key.
If i do the following query:

from LOVEJB l order by l.canonicalId
desc

my results are not ordered by the 'canonicalId' column I asked for. Instead, the canonical id result is like:

823 823 822 823 ,,,

Can someone give me some pointers on how should I try to crack this? I already messed up with hashcodes and equals, I experimented with a new class, etc. to no avail.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲欢浪云 2024-07-14 22:18:18

我发现。 我的复合键包含不属于表主键的列。 谢谢大家。

I found out. My composite key had columns that were not part of the table's primary key. Thanks all.

习ぎ惯性依靠 2024-07-14 22:18:18

实际生成的 QUERY 是什么? 顺序由 RDBMS 决定。
在 Hib 配置中打开 show_sql 并手动运行该查询。

What's the actual QUERY generated? Order is dictated by RDBMS.
Turn on show_sql in Hib configuration and run that query manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文