如何在休眠状态下持久化类的对象,而使其不具有id属性却使用其对象标识。
You can't. You have to designate a field that will hold the @Id
for the entity.
The object identity can't be translated to a database primary key, and a primary key is a requirement.
There's another thing here - the equals
and hashcode
methods are usually incorrectly implemented using the @Id
field. You can use the default implementations which rely on object identity.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.