这些 Hibernate 对象有何不同?
为什么我在Hibernate异常中得到的一些对象在用@符号打印出来时会出现这样的情况:
Cannot remove object
db.item.model.Inventory@21d321bb
但有些看起来像这样:
org.hibernate.NonUniqueObjectException: 具有相同对象的不同对象 标识符值已经 与会话关联: [db.item.model.Inventory#9369629]
# 符号后带有标识符?
Possible Duplicate:
Hibernate: different object with the same identifier value was already associated with the session
Why does some objects I get in Hibernate exceptions appear like this when they are printed out with the @ symbol:
Cannot remove object
db.item.model.Inventory@21d321bb
But some appear like this:
org.hibernate.NonUniqueObjectException:
a different object with the same
identifier value was already
associated with the session:
[db.item.model.Inventory#9369629]
With the identifier after # symbol?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
db.item.model.Inventory@21d321bb 是一个实例。
[db.item.model.Inventory#9369629] 是两个或多个@Id 为 9369629 的实例。
db.item.model.Inventory@21d321bb is a certain instance.
[db.item.model.Inventory#9369629] are two or more instances with @Id 9369629.
db.item.model.Inventory@21d321bb 指的是内存地址。
db.item.model.Inventory#9369629 引用 ID 为 9369629 的实体。
db.item.model.Inventory@21d321bb refers to a memory address.
db.item.model.Inventory#9369629 refers to an entity with ID 9369629.
#后面的标识符是表中对象的主键。
当两个具有相同标识符(主键)的对象添加到会话中时,会发生 NonUniqueObjectException。
db.item.model.Inventory@21d321bb 由默认的 equals 方法即 Object.equals() 输出。
The identifier after the # is the primary key of the object in the table.
A NonUniqueObjectException occurs when two objects with the same identifier (primary key) are added to the session.
db.item.model.Inventory@21d321bb is output by the default equals method i.e. Object.equals().