Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

Java1234官方群25:java1234官方群17
Java1234官方群25:838462530
        
SpringBoot+SpringSecurity+Vue+ElementPlus权限系统实战课程 震撼发布        

最新Java全栈就业实战课程(免费)

springcloud分布式电商秒杀实战课程

IDEA永久激活

66套java实战课程无套路领取

锋哥开始收Java学员啦!

Python学习路线图

锋哥开始收Java学员啦!
当前位置: 主页 > Java文档 > Java基础相关 >

Java Persistence API 2.0 FINAL 官方文档 PDF 下载


分享到:
时间:2020-06-19 16:56来源:http://www.java1234.com 作者:小锋  侵权举报
Java Persistence API 2.0 FINAL 官方文档 PDF 下载
失效链接处理
Java Persistence API 2.0 FINAL 官方文档  PDF 下载

本站整理下载:
 
相关截图:
 
主要内容:

2.1 The Entity Class
The entity class must be annotated with the Entity annotation or denoted in the XML descriptor as an
entity.
The entity class must have a no-arg constructor. The entity class may have other constructors as well.
The no-arg constructor must be public or protected.
The entity class must be a top-level class. An enum or interface must not be designated as an entity.
The entity class must not be final. No methods or persistent instance variables of the entity class may be
final.
Entities Java Persistence 2.0, Final Release Persistent Fields and Properties
 11/10/09 22 JSR-317 Final Release
Sun Microsystems, Inc.
If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the
entity class must implement the Serializable interface.
Entities support inheritance, polymorphic associations, and polymorphic queries. 
Both abstract and concrete classes can be entities. Entities may extend non-entity classes as well as
entity classes, and non-entity classes may extend entity classes.
The persistent state of an entity is represented by instance variables, which may correspond to Java￾Beans properties. An instance variable must be directly accessed only from within the methods of the
entity by the entity instance itself. Instance variables must not be accessed by clients of the entity. The
state of the entity is available to clients only through the entity’s methods—i.e., accessor methods (get￾ter/setter methods) or other business methods.
2.2 Persistent Fields and Properties 
The persistent state of an entity is accessed by the persistence provider runtime[1] either via JavaBeans
style property accessors (“property access”) or via instance variables (“field access”). Whether persis￾tent properties or persistent fields or a combination of the two is used for the provider’s access to a
given class or entity hierarchy is determined as described in Section 2.3, “Access Type”.
Terminology Note: The persistent fields and properties of an entity class are generically
referred to in this document as the “attributes” of the class.
The instance variables of a class must be private, protected, or package visibility independent of
whether field access or property access is used. When property access is used, the property accessor
methods must be public or protected. 
It is required that the entity class follow the method signature conventions for JavaBeans read/write
properties (as defined by the JavaBeans Introspector class) for persistent properties when property
access is used. 
In this case, for every persistent property property of type T of the entity, there is a getter method, get￾Property, and setter method setProperty. For boolean properties, isProperty may be used as an alterna￾tive name for the getter method.[2]
For single-valued persistent properties, these method signatures are:
• T getProperty() 
• void setProperty(T t)
[1] The term "persistence provider runtime" refers to the runtime environment of the persistence implementation. In Java EE envi￾ronments, this may be the Java EE container or a third-party persistence provider implementation integrated with it.
[2] Specifically, if getX is the name of the getter method and setX is the name of the setter method, where X is a string, the name of the 
persistent property is defined by the result of java.beans.Introspector.decapitalize(X).
Persistent Fields and Properties Java Persistence 2.0, Final Release Entities
JSR-317 Final Release 23 11/10/09
Sun Microsystems, Inc.
Collection-valued persistent fields and properties must be defined in terms of one of the following col￾lection-valued interfaces regardless of whether the entity class otherwise adheres to the JavaBeans
method conventions noted above and whether field or property access is used: java.util.Collec￾tion, java.util.Set, java.util.List[3], java.util.Map. The collection implementa￾tion type may be used by the application to initialize fields or properties before the entity is made
persistent. Once the entity becomes managed (or detached), subsequent access must be through the
interface type.
Terminology Note: The terms “collection” and “collection-valued” are used in this specifica￾tion to denote any of the above types unless further qualified. In cases where a
java.util.Collection type (or one of its subtypes) is to be distinguished, the type is
identified as such. The terms “map” and “map collection” are used to apply to a collection of
type java.util.Map when a collection of type java.util.Map needs to be distin￾guished as such.
For collection-valued persistent properties, type T must be one of these collection interface types in the
method signatures above. Use of the generic variants of these collection types is encouraged (for exam￾ple, Set<Order>).
In addition to returning and setting the persistent state of the instance, property accessor methods may
contain other business logic as well, for example, to perform validation. The persistence provider run￾time executes this logic when property-based access is used. 
Caution should be exercised in adding business logic to the accessor methods when property
access is used. The order in which the persistence provider runtime calls these methods when
loading or storing persistent state is not defined. Logic contained in such methods therefore
should not rely upon a specific invocation order.
If property access is used and lazy fetching is specified, portable applications should not directly access
the entity state underlying the property methods of managed instances until after it has been fetched by
the persistence provider.[4]
Runtime exceptions thrown by property accessor methods cause the current transaction to be marked for
rollback. Exceptions thrown by such methods when used by the persistence runtime to load or store per￾sistent state cause the persistence runtime to mark the current transaction for rollback and to throw a
PersistenceException that wraps the application exception.
Entity subclasses may override the property accessor methods. However, portable applications must not
override the object/relational mapping metadata that applies to the persistent fields or properties of
entity superclasses.
[3] Portable applications should not expect the order of a list to be maintained across persistence contexts unless the OrderColumn
construct is used or unless the OrderBy construct is used and the modifications to the list observe the specified ordering.
[4] Lazy fetching is a hint to the persistence provider and can be specified by means of the Basic, OneToOne, OneToMany, 
ManyToOne, ManyToMany, and ElementCollection annotations and their XML equivalents. See Chapter 11.
Entities Java Persistence 2.0, Final Release Persistent Fields and Properties
 11/10/09 24 JSR-317 Final Release
Sun Microsystems, Inc.
The persistent fields or properties of an entity may be of the following types: Java primitive types;
java.lang.String; other Java serializable types (including wrappers of the primitive types,
java.math.BigInteger, java.math.BigDecimal, java.util.Date,
java.util.Calendar[5], java.sql.Date, java.sql.Time, java.sql.Timestamp,
byte[], Byte[], char[], Character[], and user-defined types that implement the Serializable interface); enums; entity types; collections of entity types; embeddable classes (see Section
2.5); collections of basic and embeddable types (see Section 2.6).
Object/relational mapping metadata may be specified to customize the object/relational mapping and
the loading and storing of the entity state and relationships. See Chapter 11.

 

------分隔线----------------------------

锋哥公众号


锋哥微信


关注公众号
【Java资料站】
回复 666
获取 
66套java
从菜鸡到大神
项目实战课程

锋哥推荐