我有这样的注释:
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "ACK_BY", referencedColumnName = "USER_ID", nullable = true)
public User ackBy;
当我想按用户名过滤主表时,它会生成如下 sql 查询:
from ALARMS alarm0_ cross join USER user1_ where alarm0_.ACK_BY=user1_.USER_ID and (user1_.key not like 'value' or user1_.key is null)
怎么说休眠我想像这样使用左连接:
ALARMS alarm0_ left join USER user1_ on alarm0_.ACK_BY=user1_.USER_ID (user1_.key not like 'value' or user1_.key is null)
UPD:我不能使用 HQL 来解决这个问题。