如果实体中没有定义标识符,Hibernate如何在内部跟踪对象? [英] How does Hibernate keep track of object internally if no identifier is defined in the entity?

查看:81
本文介绍了如果实体中没有定义标识符,Hibernate如何在内部跟踪对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Hibernate reference doc

As per Hibernate reference doc


identifier属性是严格可选的。您可以将它们关闭
并让Hibernate在内部跟踪对象标识符。

The identifier property is strictly optional. You can leave them off and let Hibernate keep track of object identifiers internally.

Hibernate如何在内部跟踪对象如果实体中没有定义标识符?

How does Hibernate keep track of object internally if no identifier is defined in the entity?

进一步扩展问题,如果没有标识符,我们如何load()/ get()实体使其持久化?

Extending the question further, if there is no identifier how do we load()/get() the entity to make it persistence?

推荐答案

这意味着您不必自己管理标识符,也不需要实体中的属性,但您至少需要一个支持字段来存储它,并让Hibernate管理它,除了作为实体的一部分的组件以外,它们本身不具有身份。

it means you don't have to manage the identifiers yourself and don't need the property in your Entity, but you need at least a backing field to store it and let Hibernate manage it, except for Components which are parts of an Entity and dont have an identity on their own.

这篇关于如果实体中没有定义标识符,Hibernate如何在内部跟踪对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆