|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
javax.persistence Annotation Type DiscriminatorValue
@Retention(value=RUNTIME)
此类用于指定给定类型实体的鉴别符列的值。
DiscriminatorValue
注释只能对具体的实体类指定。如果没有指定 DiscriminatorValue
注释并使用了鉴别符列,则将使用特定于提供者的函数生成表示整个类型的值。如果 DiscriminatorType
为 STRING
,则鉴别符值默认为实体名称。
仅在实体类分层结构的根或应用了不同继承战略的次级分层结构中指定继承战略和鉴别符列。如果鉴别符值不是默认的,则应该为分层结构中的每个实体类指定此值。
示例: @Entity @Table(name="CUST") @Inheritance(strategy=SINGLE_TABLE) @DiscriminatorColumn(name="DISC", discriminatorType=STRING,length=20) @DiscriminatorValue("CUSTOMER") public class Customer { ... } @Entity @DiscriminatorValue("VCUSTOMER") public class ValuedCustomer extends Customer { ... }
since |
|
Is used to specify the value of the discriminator column for
entities of the given type. The DiscriminatorValue
annotation can only be specified on a concrete entity
class. If the DiscriminatorValue
annotation is not
specified and a discriminator column is used, a provider-specific
function will be used to generate a value representing the
entity type. If the DiscriminatorType
is STRING
, the discriminator value
default is the entity name.
The inheritance strategy and the discriminator column are only specified in the root of an entity class hierarchy or subhierarchy in which a different inheritance strategy is applied. The discriminator value, if not defaulted, should be specified for each entity class in the hierarchy.
Example: @Entity @Table(name="CUST") @Inheritance(strategy=SINGLE_TABLE) @DiscriminatorColumn(name="DISC", discriminatorType=STRING,length=20) @DiscriminatorValue("CUSTOMER") public class Customer { ... } @Entity @DiscriminatorValue("VCUSTOMER") public class ValuedCustomer extends Customer { ... }
- Since:
- Java Persistence 1.0
Required Element Summary | |
---|---|
String |
value
(Optional) The value that indicates that the row is an entity of the annotated entity type. |
Element Detail |
---|
abstract public String
value()
(可选)表示行是注释的实体类型的值。
如果没有指定 DiscriminatorValue
注释并使用了鉴别符列,则将使用特定于提供者的函数生成表示整个类型的值。如果 DiscriminatorType 为 STRING
,则鉴别符值默认为实体名称。
value
public abstract String value
- (Optional) The value that indicates that the
row is an entity of the annotated entity type.
If the
DiscriminatorValue
annotation is not specified and a discriminator column is used, a provider-specific function will be used to generate a value representing the entity type. If the DiscriminatorType isSTRING
, the discriminator value default is the entity name.
|
|||||||||
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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!