与collectionTable一起使用时,将忽略@JoinColumn referencedColumnName指定的值

时间:2015-03-27 10:56:54

标签: hibernate jpa

我有下面提到的配置,这里我希望集合表joincolumn(foriegn key)应该指向Subclass primarykey

配置:

@DependencySubclasses({LookupTypeOne.class, LookupTypeTwo.class})
@CodeReview(status = ReviewStatus.PENDING, reviewer = "")
@Entity
@Table(name = "LOOKUP_TABLE")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class AbstractLookup {

@GsonExclude
@Id
@GeneratedValue(generator = UID_GENERATOR)
@Column(name = "LOOKUP_ID")
protected Long lookupId;
//.......
}

@CodeReview(status = CodeReview.ReviewStatus.PENDING, reviewer = "")
@Entity
@Table(name = LOOKUP_CURVE_TABLE)
@PrimaryKeyJoinColumn(name = "LOOKUP_CURVE_ID")
public class LookupTypeOne extends AbstractLookup {

@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "COLLECTION_TABLE", joinColumns =   @JoinColumn(name = "CT_LT_ID", referencedColumnName = "LOOKUP_CURVE_ID", nullable = false))
private List<ParameterTableColumn> varyByParameterItems = Lists.newArrayList();

//...........

}

@Embeddable
public class ParameterTableColumn {
@Dependency(DEFINITION)
private Long columnObjectId;
//.......
}

所以在LookupTypeOne实现集合表joinColumn(foriegn key)我想引用&#34; Lookup_CURVE_ID&#34;即LookupTypeOne的主键,它应该作为referencedColumnName =&#34; LOOKUP_CURVE_ID&#34;已指定,但仍然是对AbstractLookup的id的引用,即&#34; LOOKUP_ID&#34;

从配置来看,这应该可行,但我认为它不能正常工作。如果有人可以指出哪些是错误的,以及将其引用到&#34; LOOKUP_CURVE_ID&#34;那将会有很大的帮助。

所以这里的问题是为什么referencedColumnName =&#34; LOOKUP_CURVE_ID&#34;没有任何区别,似乎被忽略了?

0 个答案:

没有答案