1
我有具有兩個查找值(一個用於名稱,一個用於類型)休眠OnetoOne映射具有兩個查找值
public class someAttr {
private Long someAttrId;
private Long projectId;
private Lookup typeLookupValue;
private Lookup nameLookupValue;
getters & setter...
@OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
@JoinColumn(name = "type_lk_id", referencedColumnName = "lk_id", insertable = false, updatable = false)
public LookupValue getTypeLookupValue() {
return typeLookupValue;
}
public void setTypeLookupValue(Lookup typeLookupValue) {
this.typeLookupValue= typeLookupValue;
}
@OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
@JoinColumn(name = "name_lk_id", referencedColumnName = "lk_id", insertable = false, updatable = false)
public LookupValue getNameLookupValue() {
return nameLookupValue;
}
public void setNameLookupValue(Lookup nameLookupValue) {
this.nameLookupValue= nameLookupValue;
}
的問題是,在同一name_lk_id被不同someAttr對象之間共享的類。 每次運行它時,我都會得到: 「org.hibernate.HibernateException:找到多於一行的給定標識符」。
我可以通過projectId獲得屬於特定someAttr的nameLookupValue,而不是使用相同的「lk_id」獲取多個Lookup對象?
非常感謝,可能你們兩個爲我節省了大量的時間(可能還有很多我的頭髮;)) – uthomas 2012-01-14 15:42:30