Hibernate session.get() UUID 字符串 ID 问题

发布于 2024-09-16 16:47:10 字数 270 浏览 5 评论 0原文

我在使用休眠时遇到问题。

mysql表中ID的主键是UUID样式的String。例如08fe2a75-5d40-4645-896d-aab2a3ac96b8

但由于某种原因我无法使用 session.get() 来获取数据。

Software software=(Software)session.get(Software.class, id);

看起来整数 ID 没问题。

请指教

I am having a problem with Hibernate.

The primary key of ID in mysql table is UUID style String. e.g.08fe2a75-5d40-4645-896d-aab2a3ac96b8

But I can not use session.get() to fetch out the data for some reason.

Software software=(Software)session.get(Software.class, id);

It seems ok with integer IDs.

Please advise

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

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

发布评论

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

评论(1

时光沙漏 2024-09-23 16:47:10

激活生成的 SQL 的日志记录以查看到底发生了什么。这可以通过在 Hibernate 配置中设置以下属性来完成:

<property name="hibernate.show_sql" value="true"/>

或者在日志记录后端的配置中设置以下类别进行调试。

org.hibernate.SQL

将生成的查询与预期结果(在 SQL 客户端中有效)进行比较。

参考

Activate the logging of the generated SQL to see what is happening exactly. This can be done by setting the following property in your Hibernate configuration:

<property name="hibernate.show_sql" value="true"/>

Or set the following category to debug in the configuration of your logging backend.

org.hibernate.SQL

Compare the generated query with the expected result (that works in your SQL client).

Reference

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