JoinTable (Java EE 5)

Java EE API


javax.persistence Annotation Type JoinTable


@Target(value={METHOD,FIELD})
@Retention(value=RUNTIME)
public @interface JoinTable

Implements: Annotation
@Target(value={METHOD, FIELD})
@Retention(value=RUNTIME)

此注释在关联映射中使用。它是在多对多关联的拥有端或单向的一对多关联中指定的。

如果缺少 JoinTable 注释,则应用注释元素的默认值。连接表格的名称假定为使用下划线串接起来的关联主表格的表格名称(拥有端在最前面)。

示例:
    @JoinTable(
    name="CUST_PHONE",
    joinColumns=
        @JoinColumn(name="CUST_ID", referencedColumnName="ID"),
    inverseJoinColumns=
        @JoinColumn(name="PHONE_ID", referencedColumnName="ID")
    )
 
英文文档:

This annotation is used in the mapping of associations. It is specified on the owning side of a many-to-many association, or in a unidirectional one-to-many association.

If the JoinTable annotation is missing, the default values of the annotation elements apply. The name of the join table is assumed to be the table names of the associated primary tables concatenated together (owning side first) using an underscore.

    Example:
    @JoinTable(
    name="CUST_PHONE",
    joinColumns=
        @JoinColumn(name="CUST_ID", referencedColumnName="ID"),
    inverseJoinColumns=
        @JoinColumn(name="PHONE_ID", referencedColumnName="ID")
    )
 

Since:
Java Persistence 1.0

Optional Element Summary
 String
 JoinColumn[]
 JoinColumn[]
 String
 String
 UniqueConstraint[]
 

abstract public String name()
(可选)连接表格的名称。

默认为串接起来的两个关联主实体表格的名称(使用下划线分隔)。

英文文档:

name

public abstract String name
(Optional) The name of the join table.

Defaults to the concatenated names of the two associated primary entity tables, separated by an underscore.

Default:
""

abstract public String catalog()
(可选)表格的种类。

默认为默认种类。

英文文档:

catalog

public abstract String catalog
(Optional) The catalog of the table.

Defaults to the default catalog.

Default:
""

abstract public String schema()
(可选)表格的模式。

默认为用户的默认模式。

英文文档:

schema

public abstract String schema
(Optional) The schema of the table.

Defaults to the default schema for user.

Default:
""

abstract public JoinColumn[] joinColumns()
(可选)连接表格的外键列,它们引用拥有关联的实体的主表格(即关联的拥有端)。

使用与 JoinColumn 相同的默认值。

英文文档:

joinColumns

public abstract JoinColumn[] joinColumns
(Optional) The foreign key columns of the join table which reference the primary table of the entity owning the association (i.e. the owning side of the association).

Uses the same defaults as for JoinColumn.

Default:
{}

abstract public JoinColumn[] inverseJoinColumns()
(可选)连接表格的外键列,它们引用不拥有关联的实体的主表格(即关联的反向端)。

使用与 JoinColumn 相同的默认值。

英文文档:

inverseJoinColumns

public abstract JoinColumn[] inverseJoinColumns
(Optional) The foreign key columns of the join table which reference the primary table of the entity that does not own the association (i.e. the inverse side of the association).

Uses the same defaults as for JoinColumn.

Default:
{}

abstract public UniqueConstraint[] uniqueConstraints()
(可选)对表格设置的唯一约束。仅当表格生成生效时使用。

默认为无额外限制。

英文文档:

uniqueConstraints

public abstract UniqueConstraint[] uniqueConstraints
(Optional) Unique constraints that are to be placed on the table. These are only used if table generation is in effect.

Defaults to no additional constraints.

Default:
{}


Submit a bug or feature

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

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

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