SecondaryTables (Java EE 5)

Java EE API


javax.persistence Annotation Type SecondaryTables


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

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

此注释用于为实体类指定多个从属表格。
示例 1:多个从属表格,假定所有表格中的主键列名称相同。

@Entity
    @Table(name="EMPLOYEE")
    @SecondaryTables({
        @SecondaryTable(name="EMP_DETAIL"),
        @SecondaryTable(name="EMP_HIST")
    })
    public class Employee { ... }
    
示例 2:指定了不同主键列的多个从属表格。 

 @Entity
    @Table(name="EMPLOYEE")
    @SecondaryTables({
        @SecondaryTable(name="EMP_DETAIL", 
            pkJoinColumns=@PrimaryKeyJoinColumn(name="EMPL_ID")),
        @SecondaryTable(name="EMP_HIST", 
            pkJoinColumns=@PrimaryKeyJoinColumn(name="EMPLOYEE_ID"))
    })
    public class Employee { ... }
 
英文文档:

This annotation is used to specify multiple secondary tables for an entity.

    Example 1: Multiple secondary tables assuming primary key columns are named the same in all tables.

    @Entity
    @Table(name="EMPLOYEE")
    @SecondaryTables({
        @SecondaryTable(name="EMP_DETAIL"),
        @SecondaryTable(name="EMP_HIST")
    })
    public class Employee { ... }
    
    Example 2: Multiple secondary tables with differently named primary key columns. 

    @Entity
    @Table(name="EMPLOYEE")
    @SecondaryTables({
        @SecondaryTable(name="EMP_DETAIL", 
            pkJoinColumns=@PrimaryKeyJoinColumn(name="EMPL_ID")),
        @SecondaryTable(name="EMP_HIST", 
            pkJoinColumns=@PrimaryKeyJoinColumn(name="EMPLOYEE_ID"))
    })
    public class Employee { ... }
 

Since:
Java Persistence 1.0

Required Element Summary
 SecondaryTable[]
 

Element Detail

abstract public SecondaryTable[] value()
实体的从属表格。
英文文档:

value

public abstract SecondaryTable[] value
The secondary tables for an entity.



Submit a bug or feature

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

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

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