Case: Hibernate: Value Type

来源:互联网 发布:商家怎么加入农村淘宝 编辑:程序博客网 时间:2024/04/27 16:08

Example in <Java Persistence with Hibernate>: Item's Images.

Example in Filed Experience: Supplier Site's Contacts.

Another possible example: Attachment?


Quoted from <Java Persistence with Hibernate>:

More formally, an entity is any class whose instances have their own persistent identity. A value type is a class that doesn't define some kind of persistent identity. In practice, this means that entity types are classes with identifier properties, and value type classes depend on an entity.

Therefore, entities have their own lifecycle. The save() and delete() methods of the Hibernate Session interface apply to instances of entity classes, never to value type instances. The persistence lifecycle of a value type instance is completely tied to the lifecycle of the owning entity instance.


原创粉丝点击