2010-03-26 203 views
2

我試圖映射實體映射@OneToOne與@Where條款

@OneToOne(mappedBy = "localizedLabel") 
@JoinColumn(insertable = false, updatable = false) 
@WhereJoinTable(clause = "locale='en_US'") 
public Localization getEn_US() { 
    return en_US; 
} 

我可以保證數據將只返回一個空或者如果沒有找到,但休眠似乎忽略我@ Where子句:

ERROR com.eventtouch.bc.business.core.log.LoggingInterceptor - org.hibernate.HibernateException: More than one row with the given identifier was found: 4211, for class: com.eventtouch.bc.business.domain.LocalizedLabel 

任何有關使用@Where子句映射@OneToOne關係的想法嗎?

感謝

回答

0

你@OneToOne似乎不使用連接表。

在這種情況下,您不應該使用@Where註釋而不是@WhereJoinTable來過濾連接表的行嗎?

+1

我做到了,但錯誤仍然存​​在! – Gabriel 2010-04-23 08:56:33

0

當您使用@JoinColumn引用列在源表中創建(因爲它是一對一關聯),因此避免創建連接表。