Entities support class inheritance, polymorphic associations, and polymorphic queries. They can extend non-entity classes, and non-entity classes can extend entity classes. Entity classes can be both abstract and concrete.
1) Abstract Entities
An abstract class may be declared an entity by decorating the class with @Entity. Abstract entities differ from concrete entities only in that they cannot be instantiated.
Abstract entities can be queried just like concrete queries. If an abstract entity is the target of a query,
the query operates on all the concrete subclasses of the abstract entity.
2) Mapped Superclasses
Entities may inherit from superclasses that contain persistent state and mapping information,but are not entities. That is, the superclass is not decorated with the @Entity annotation, and is not mapped as an entity by the Java Persistence provider. These superclasses are most often used when you have state and mapping information common to multiple entity classes.
Mapped superclasses are not queryable, and can’t be used in EntityManager or Query operations. You must use entity subclasses of the mapped superclass in EntityManager or Query operations.Mapped superclasses can’t be targets of entity relationships.Mapped superclasses can be abstract or concrete.
Mapped superclasses do not have any corresponding tables in the underlying datastore. Entities that inherit from the mapped superclass define the table mappings
3)Non-Entity Superclasses
Entities may have non-entity superclasses, and these superclasses can be either abstract or concrete. The state of non-entity superclasses is non-persistent, and any state inherited from the non-entity superclass by an entity class is non-persistent.Non-entity superclasses may not be used in EntityManager or Query operations. Any mapping or relationship annotations in non-entity superclasses are ignored.
4) Entity InheritanceMapping Strategies
You can configure how the Java Persistence provider maps inherited entities to the underlying datastore by decorating the root class of the hierarchy with the
javax.persistence.Inheritance annotation. There are three mapping strategies that are used to map the entity data to the underlying database:
■ A single table per class hierarchy
■ A table per concrete entity class
■ A “join” strategy, where fields or properties that are specific to a subclass are mapped to a different table than the fields or properties that are common to the parent class
分享到:
相关推荐
赠送jar包:hibernate-jpa-2.1-api-1.0.2.Final.jar; 赠送原API文档:hibernate-jpa-2.1-api-1.0.2.Final-javadoc.jar; 赠送源代码:hibernate-jpa-2.1-api-1.0.2.Final-sources.jar; 赠送Maven依赖信息文件:...
赠送jar包:hibernate-jpa-2.1-api-1.0.2.Final.jar; 赠送原API文档:hibernate-jpa-2.1-api-1.0.2.Final-javadoc.jar; 赠送源代码:hibernate-jpa-2.1-api-1.0.2.Final-sources.jar; 赠送Maven依赖信息文件:...
hibernate-jpa-2.1-api-1.0.0.final-sources.jar 源码 hibernate-jpa-2.1-api-1.0.0.final-sources.jar 源码
hibernate-jpa-2.0-api-1.0.1.Final-sources.jar hibernate jpa 源代码
`hibernate-jpa-2.1-api-1.0.0.final.jar`是Hibernate对JPA 2.1规范的实现库,它使得开发者能够使用Hibernate的高效功能同时遵循JPA规范。 **1. Hibernate与JPA的关系** Hibernate最初作为一个独立的ORM框架,后来...
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar官方下载,请放心使用
java.lang.NoClassDefFoundError: javax/persistence/spi/ProviderUtil 或javax/persistence/entitylistener问题
jpa-spec 在Spring Data JPA之上做扩展,支持原生JPA2规范,极大的简化动态查询语法。特性兼容JPA2规范Equal/NotEqual/Like/In 支持多个参数, Equal/NotEqual 支持Null 值.构建器风格创建查询条件支持分页与构建器...
java运行依赖jar包
- **配置Repository**:定义接口继承`JpaRepository`或自定义方法,JPA会自动实现这些方法。 - **编写业务逻辑**:在服务层实现业务操作,调用Repository中的方法。 - **测试**:编写JUnit测试用例,验证JPA功能...
【标题】"myfaces-extcdi-jpa1-module-impl-1.0.6.zip" 涉及的是一款开源项目中的模块实现,主要关注MyFaces扩展CDI(Contexts and Dependency Injection)与JPA(Java Persistence API)的集成。MyFaces是Apache...
本篇文章将重点围绕“hibernate-jpa-2.1-api-1.0.0.final-sources.jar.zip”这一压缩包,深入解析Hibernate对JPA 2.1 API的实现,以期帮助读者深入理解其内部机制。 JPA(Java Persistence API)是Java平台上的一个...
这个源码包"hibernate-jpa-2.0-api-1.0.1.Final-sources"包含了完整的源代码,可以帮助我们深入了解其内部机制,从而更好地应用在实际项目中。 1. **JPA简介**:Java Persistence API(JPA)是Java平台上的一个标准...
antlr-2.7.6.jar, cglib-2.2.jar, commons-collections-3.1.jar, ...hibernate-jpa-2.0-api-1.0.0.Final.jar, javassist-3.9.0.GA.jar, jta-1.1.jar, slf4j-api-1.6.1.jar, slf4j-log4j12-1.6.1.jar
java运行依赖jar包
**JPA 开发文档——全面解析** 1. **发展中的持久化技术** - **JDBC**: JDBC(Java Database Connectivity)是Java语言中用来规范客户端程序如何连接数据库的应用编程接口,提供了一种标准的方式来访问各种关系...