- Specifies the primary key of an entity.
- Is used to specify the mapped column for a persistent property or field.
- If no Column annotation is specified, the default values apply.
- 如果名稱相同,則不需要使用此指定。
Annotation GeneratedValue
- Provides for the specification of generation strategies for the values of primary keys.
- String generator
- (Optional) The name of the primary key generator to use as specified in the SequenceGenerator or TableGenerator annotation.
- GenerationType strategy (Refer the next)
- (Optional) The primary key generation strategy that the persistence provider must use to generate the annotated entity primary key.
- Default value:
- javax.persistence.GenerationType.AUTO
Enum GenerationType
- GenerationType AUTO
- Default for Annotation GeneratedValue
- GenerationType IDENTITY
- GenerationType SEQUENCE
- Indicates that the persistence provider must assign primary keys for the entity using a database sequence.
- GenerationType TABLE
Annotation ManyToOne
- Defines a single-valued association to another entity class that has many-to-one multiplicity.
- It is not normally necessary to specify the target entity explicitly since it can usually be inferred from the type of the object being referenced.
- The ManyToOne annotation may be used within an embeddable class to specify a relationship from the embeddable class to an entity class.
- CascadeType[] cascade
- (Optional) The operations that must be cascaded to the target of the association.
- By default no operations are cascaded.
- FetchType fetch
- (Optional) (refer the following items)
- Default value:
- javax.persistence.FetchType.EAGER
Enum CascadeType
- Defines the set of cascadable operations that are propagated to the associated entity.
- The value cascade=ALL is equivalent to cascade={PERSIST, MERGE, REMOVE, REFRESH, DETACH}.
Enum FetchType
- Defines strategies for fetching data from the database.
- The EAGER strategy
- A requirement on the persistence provider runtime that data must be eagerly fetched.
- The LAZY strategy
- A hint to the persistence provider runtime that data should be fetched lazily when it is first accessed.
- The implementation is permitted to eagerly fetch data for which the LAZY strategy hint has been specified.
Annotation JoinColumn
- Specifies a column for joining an entity association or element collection.
- String referencedColumnName
Interface CriteriaBuilder
- Used to construct criteria queries, compound selections, expressions, predicates, orderings.
- Note that Predicate is used instead of Expression in this API in order to work around the fact that Java generics are not compatible with varags. (?)
Interface CriteriaQuery<T>
- The CriteriaQuery interface defines functionality that is specific to top-level queries.
Interface Root<X>
- A root type in the from clause. Query roots always reference entities.
* Reference
- JPA Reference (JavaDoc)
沒有留言:
張貼留言