我有一些逻辑删除的记录(即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;
但是,hibernate 似乎WhereJoinTable
没有使用 (也许它只对OneToMany
? 有效),因为active=true
没有出现在生成的 SQL(日志)中并且问题仍然存在。
是否可以包含用于连接 a 的 where 子句ManyToOne
以及如何连接?