开发者

Mapping @OneToOne with @Where clause

I am trying to map an entity as following

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

I can assure that the data will return only one or null if the not found, but hibernate seems to ignore my @Where clause:

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

Any ideas on ho to map a @OneToOne relationship with @Where clause?

Thanks


Your @OneToOne does not seem to use a join table.

In that case, shouldn't you use a @Where annotation rather than the @WhereJoinTable that filters rows of a join table ?


When you use @JoinColumn reference column is created in source table (as it is one to one association) this avoid creating a join table.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜