【发布时间】:2014-09-15 02:17:44
【问题描述】:
HQL 连接查询有问题。谁能告诉我下面的加入 HQL 查询有什么问题? 我正在使用 Hibernate 4.3.6、JDK 7 和 Groovy 2.2
def query = 'select lip.referenceId from Parcel as lip left join TransportFile tf where lip.statusDisplayName != tf.statusDisplayName'
def hqlQuery = session.createQuery(query)
def hqlcount = hqlQuery.list().size
当我运行上面的代码时出现以下错误
com.dc.core.common.exception.BaseApplicationException: org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join! [select lip.referenceId from com.dc.apps.cp.ebilling.model.impl.Parcel as lip left join TransportFile tf where lip.statusDisplayName != tf.statusDisplayName]
下面是我的包裹实体
package com.dc.apps.cp.ebilling.model.impl
@Entity
@Audited
public class Parcel implements IPersistentEntityInstance {
private static final long serialVersionUID = 1L;
private Long id;
@AttributeReadPermission(name = "SUBMITTEDFILE.READ")
@AttributeWritePermission(name = "SUBMITTEDFILE.UPDATE")
private File submittedFile;
private ParcelType type;
private boolean isBeingSubmitted;
private TransportFile transportFile;
}
下面是我的 TransportFile 实体
package com.dc.apps.cp.legacy.model.impl;
@Entity
@EntityMetadataDefaults(editable = false)
public class TransportFile implements ITransportObject {
private static final long serialVersionUID = 1L;
private Long id;
private String statusDisplayName;
// [ReferenceID] [varchar](30) NOT NULL
private String referenceId;
// [sent] [datetime] NULL,
private Timestamp sentDate;
// [received] [datetime] NULL,
private Timestamp receivedDate;
// [Status] [varchar](4) NULL,
private String statusCode;
private List<TransportLog> TransportLogs;
private String rejectionReason;
}
我参考了这篇帖子 HQL left join: Path expected for join,但我的 HQL 连接查询没有发现任何问题。
【问题讨论】:
标签: sql hibernate join groovy hql