gpt4 book ai didi

hibernate - 使用@Where 子句映射@OneToOne

转载 作者:行者123 更新时间:2023-12-05 01:28:34 25 4
gpt4 key购买 nike

我正在尝试将实体映射如下

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

我可以保证,如果未找到,数据将只返回 1 或 null,但 hibernate 似乎忽略了我的 @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

关于将@OneToOne 关系与@Where 子句进行映射的任何想法?

谢谢

最佳答案

您的 @OneToOne 似乎没有使用连接表。

在这种情况下,您不应该使用 @Where 注释而不是过滤连接表行的 @WhereJoinTable 吗?

关于hibernate - 使用@Where 子句映射@OneToOne,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2523138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com