在同一实体上在 Hibernate 中左加入并具有其他条件

问题描述 投票:0回答:0

我需要使用 Hibernate 3.3.2 对 java 项目进行一些性能修复(无法升级)。有一个内部查询 - 不符合条件。在简化过程中,我想将其重写为左外连接。但我在 HQL 语法上遇到了困难。我用谷歌搜索了很多,尝试了很多尝试,阅读了doc,但我完全失败了。

public class Document implements {
    Long recordId, documentId;
    String status;

public class Data {
    Long dataId;

原HQL:

from Document ln where ln.status = 'Active' and ln.recordId not in 
(select ln.recordId from Document ln, Data cd where ln.status = 'Active' and ln.documentId = cd.dataId))

我的最新修订版因语法错误而失败:

select ln from Document as ln 
left join Document.recordId as lne with lne.status='Active' 
left join Data as cd with lne.documentId=cd.dataId 
where ln.loanDocumentStatus='Active' and lne.recordId is null 
java hibernate
© www.soinside.com 2019 - 2024. All rights reserved.