等效于@CollectionElement属性(JPA)

时间:2014-07-16 08:50:33

标签: java jpa attributes annotations

对于不属于列表的简单属性,是否存在类似@CollectionElement注释的内容?

我想为我的实体添加一个属性而不是列,而是另一个表。

例如像这样的东西(知道这不起作用/存在......):

@ElementAttribute
@AttributeTable(
      name="THE_ATTRIBUTE_TABLE"
)
@Column(name="ATTRIBUTE")
private String attribute;

1 个答案:

答案 0 :(得分:1)

来自Pro JPA 2.0书:

  通过使用,可以在多个表中映射

实体   @SecondaryTable注释及其复数@SecondaryTables

例如,着名的员工实体:

@SecondaryTable(name="EMP_ATTRIBUTES")
@Entity
public class Employee {
  @Id private int id;
  @Column(table="EMP_ATTRIBUTES")
  private String attribute;
}