DiscriminatorColumn (Java EE 5)

Java EE API


javax.persistence Annotation Type DiscriminatorColumn


@Target(value=TYPE)
@Retention(value=RUNTIME)
public @interface DiscriminatorColumn

Implements: Annotation
@Target(value=TYPE)
@Retention(value=RUNTIME)

用于为 @link InheritanceType#SINGLE_TABLE SINGLE_TABLE} 和 JOINED 继承映射战略定义鉴别符列。

仅在实体类分层结构的根或应用了不同继承战略的次级分层结构中指定战略和鉴别符列

如果缺少 DiscriminatorColumn 注释,并且需要鉴别符列,则鉴别符列的名称默认为 "DTYPE",鉴别符类型默认为 DiscriminatorType.STRING

示例:
     @Entity
     @Table(name="CUST")
     @Inheritance(strategy=SINGLE_TABLE)
     @DiscriminatorColumn(name="DISC", discriminatorType=STRING,length=20)
     public class Customer { ... }

     @Entity
     public class ValuedCustomer extends Customer { ... }
 
英文文档:

Is used to define the discriminator column for the SINGLE_TABLE and JOINED inheritance mapping strategies.

The 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

If the DiscriminatorColumn annotation is missing, and a discriminator column is required, the name of the discriminator column defaults to "DTYPE" and the discriminator type to DiscriminatorType.STRING.

     Example:
     @Entity
     @Table(name="CUST")
     @Inheritance(strategy=SINGLE_TABLE)
     @DiscriminatorColumn(name="DISC", discriminatorType=STRING,length=20)
     public class Customer { ... }

     @Entity
     public class ValuedCustomer extends Customer { ... }
 

Since:
Java Persistence 1.0

Optional Element Summary
 String
 DiscriminatorType
 int
 String
 

abstract public String name()
(可选)用作鉴别符的列名称。
英文文档:

name

public abstract String name
(Optional) The name of column to be used for the discriminator.

Default:
"DTYPE"

abstract public DiscriminatorType discriminatorType()
(可选)用作类鉴别符的对象/列类型。默认为 DiscriminatorType.STRING
英文文档:

discriminatorType

public abstract DiscriminatorType discriminatorType
(Optional) The type of object/column to use as a class discriminator. Defaults to DiscriminatorType.STRING.

Default:
STRING

abstract public String columnDefinition()
(可选)生成该鉴别符列时使用的 SQL 句段。

默认为提供者生成的 SQL,以创建指定鉴别符类型的列。

英文文档:

columnDefinition

public abstract String columnDefinition
(Optional) The SQL fragment that is used when generating the DDL for the discriminator column.

Defaults to the provider-generated SQL to create a column of the specified discriminator type.

Default:
""

abstract public int length()
(可选)基于 String 的鉴别符类型的列长。其他鉴别符类型忽略此属性。
英文文档:

length

public abstract int length
(Optional) The column length for String-based discriminator types. Ignored for other discriminator types.

Default:
31


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!