[英]What is the difference between Entity and Persistent class?
I am going through the Hibernate Documentation where the author used the terms persistent class
to refer to entities
.我正在浏览Hibernate 文档,其中作者使用术语persistent class
来指代entities
。
The author says, Not all user-defined classes with a persistent state, however, are entities...作者说,并非所有具有持久状态的用户定义类都是实体......
I am unable to differentiate between the two.我无法区分两者。 Please suggest.请建议。
Hibernate defines the persistent class as any classes that can be persisted to the database. Hibernate 将持久类定义为可以持久化到数据库的任何类。
There are two types of persistent classes : entity type and value type .有两种类型的持久类:实体类型和值类型。 So entity is one type of the persistent class.所以实体是持久化类的一种。
Entity type are those classes that are marked with @Entity
while value type are those classes marked with @Embeddable
or some basic Java type such as String
, Integer
, Date
etc.实体类型是那些用@Entity
标记的类,而值类型是那些用@Embeddable
或一些基本 Java 类型(如String
、 Integer
、 Date
等)标记的类。
The main difference between them is that value type does not define their own life-cycle.They are "owned" by entity type which defines their life-cycle.它们之间的主要区别在于值类型不定义自己的生命周期。它们由定义其生命周期的实体类型“拥有”。
We create an entity type class which contains many value type classes.我们创建了一个包含许多值类型类的实体类型类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.