简体   繁体   English

实体类和持久类有什么区别?

[英]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 类型(如StringIntegerDate等)标记的类。

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.

相关问题 @Entity和@embeddable有什么区别 - What is difference between @Entity and @embeddable Hibernate和JPA之间的@Entity有什么区别 - What is the difference between @Entity in Hibernate and JPA @Entity 和 @Repository 注释有什么区别? - What is the difference between @Entity and @Repository annotations? JPA2 Criteria API:在from子句中使用Entity.class和Metamodel的EntityType有什么区别 - JPA2 Criteria API: What is the difference between using Entity.class and the EntityType of the Metamodel in the from clause 获取实体管理器的休眠会话时,“ getDelegate()”和“ unwrap()”之间有什么区别 - What is the difference between 'getDelegate()' and 'unwrap()' for getting the Hibernate session of an entity manager 使用Hibernate时@Immutable和@Entity(mutable=false)有什么区别 - What is the difference between @Immutable and @Entity(mutable=false) when using Hibernate 持久实体“*******”在@Entity 类中应该有主键错误 - Persistent entity '*******' should have primary key error in @Entity class ehcache上的@Cacheable方法和@Cacheable类有什么区别 - What's the difference between @Cacheable Method and @Cacheable Class on ehcache 返回this和return new Class()有什么区别 - what is the difference between return this vs return new Class() org.hibernate.MappingException:持久性 class 未知:对于非实体 class - org.hibernate.MappingException: persistent class not known: for non entity class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM