OpenJPA is the open source implementation of Java Persistence API. It has been integrated with the Weblogic, WebSphere, and Geronimo application servers. JPA provides an agnostic Java-based API for storing and retrieving information to a backend database. It has a canonical query language named Java Persistence Query Language, or JPQL, that blends with the programming methods of Java and eliminates the need to tailor database queries for a particular database. However, JPA also supports native SQL which can be used for quick ports with a known backend database.
You'll need three artifacts to implement a JPA-compliant program:
- An entity class
- A persistence.xml file
- A class through which you will insert, update, or find an entity
- JPA allows persistent classes to inherit from non-persistent classes, persistent classes to inherit from other persistent classes, and non-persistent classes to inherit from persistent classes.
- The entity class should have a default no-argument constructor.
- The entity class should not be final.
-
Persistent classes cannot inherit from certain natively-implemented system classes such as
java.net.Socketandjava.lang.Thread. - If a persistent class inherits from a non-persistent class, the fields of the non-persistent super class cannot be persisted.
-
@PostLoad -
@PrePersist -
@PostPersist -
@PreUpdate -
@PostUpdate -
@PreRemove -
@PostRemove
本文详细介绍了OpenJPA作为Java持久化API的开源实现,如何与Weblogic、WebSphere和Geronimo应用服务器集成,以及它如何通过提供无数据库特定的Java API来存储和检索信息到后端数据库。文章还阐述了OpenJPA中的关键组件、实体类的设计、继承规则以及回调方法的概念。
289

被折叠的 条评论
为什么被折叠?



