|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
javax.persistence Annotation Type ManyToOne
Implements:
Annotation
@Target(value={METHOD, FIELD})@Retention(value=RUNTIME)
此注释定义对另一个带有多对一多样性的实体类的单值关联。一般不必显式指定目标实体,因为通常可以根据引用的对象类型推断出来。
示例: @ManyToOne(optional=false) @JoinColumn(name="CUST_ID", nullable=false, updatable=false) public Customer getCustomer() { return customer; }
since |
|
This annotation 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.
Example: @ManyToOne(optional=false) @JoinColumn(name="CUST_ID", nullable=false, updatable=false) public Customer getCustomer() { return customer; }
- Since:
- Java Persistence 1.0
Optional Element Summary | |
---|---|
CascadeType[] |
cascade
(Optional) The operations that must be cascaded to the target of the association. |
FetchType |
fetch
(Optional) Whether the association should be lazily loaded or must be eagerly fetched. |
boolean |
optional
(Optional) Whether the association is optional. |
Class |
targetEntity
(Optional) The entity class that is the target of the association. |
abstract public Class<T>
targetEntity()
(可选)作为关联目标的实体类。
默认为存储关联的字段或属性的类型。
targetEntity
public abstract Class targetEntity
- (Optional) The entity class that is the target of
the association.
Defaults to the type of the field or property that stores the association.
- Default:
- void.class
abstract public CascadeType[]
cascade()
(可选)必须串联到关联目标的操作。
默认情况下,不串联任何操作。
cascade
public abstract CascadeType[] cascade
- (Optional) The operations that must be cascaded to
the target of the association.
By default no operations are cascaded.
- Default:
- {}
abstract public FetchType
fetch()
(可选)关联应该延迟加载还是必须立即获取。EAGER
战略是必须立即获取关联实体的持久性提供者运行时的要求。LAZY
战略是持久性提供者运行时的提示。
英文文档:
fetch
public abstract FetchType fetch
- (Optional) Whether the association should be lazily
loaded or must be eagerly fetched. The
EAGER
strategy is a requirement on the persistence provider runtime that the associated entity must be eagerly fetched. TheLAZY
strategy is a hint to the persistence provider runtime. - Default:
- EAGER
abstract public boolean
optional()
(可选)关联是否是可选的。如果设置为 false,则必须总是存在非 null 关系。
英文文档:
optional
public abstract boolean optional
- (Optional) Whether the association is optional. If set
to false then a non-null relationship must always exist.
- Default:
- true
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!