2014-07-16 104 views
0

有没有类似@CollectionElement注释的简单属性不在列表中?等效于@CollectionElement属性(JPA)

我想给我的实体添加一个属性,而不是在列中,而是在不同的表中。

例如这样的事情(知道这不工作/存在..):

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

回答

1

从临JPA 2.0书:

实体可以跨越多个表通过使被映射使用 @SecondaryTable注释和其复数@SecondaryTables

例如与知名Employee实体:

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