基本上,这可能吗?
文档说
A component is a contained object that is persisted as a value type and not an entity reference.
Like value types, components do not support shared references. In other words, two persons could have the same name, but the two person objects would contain two independent name objects that were only "the same" by value.
The main distinguishing characteristic of a value type is the fact that they do not define their own lifecycle. We say that they are "owned" by something else (specifically an entity, as we will see later) which defines their lifecycle.
非静态内部类可以完美地适应这一点,但我从未见过实践中的例子。使用内部类作为组件有什么限制吗?
最佳答案
JPA 规范说:
Embeddable classes must adhere to the requirements specified in Section 2.1 for entities with the excep- tion that embeddable classes are not annotated as Entity.
第 2.1 节说:
The entity class must be a top-level class.
关于java - 内部类作为 hibernate 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27745374/