【发布时间】:2012-04-30 02:36:56
【问题描述】:
我有一些逻辑删除的记录(即active=false)导致我的@ManyToOne 映射出现问题,因为连接列返回了多个结果。
我只需要包含active=true 我认为可以通过以下方式实现的记录:
@ManyToOne
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "site_id", referencedColumnName = "site_id", insertable = false, updatable = false)
@WhereJoinTable(clause = "active=true")
private Site site;
但是,WhereJoinTable 似乎没有被 hibernate 使用(也许它只对OneToMany 有效?)因为active=true 没有出现在生成的 SQL(日志)中并且问题仍然存在。
是否可以包含用于连接 ManyToOne 的 where 子句以及如何加入?
【问题讨论】: