在執行下面的代碼路徑,我得到這個例外HQL左連接 - org.hibernate.hql.internal.ast.ErrorCounter - 預期加入
ERROR org.hibernate.hql.internal.ast。 ErrorCounter - 預計路徑 加入!
實體類DB觀點:對數據庫表
@NamedQueries({
@NamedQuery(name = "find",
query = "SELECT v.cxxx, trk.cxxx, trk.ixxx"
+ "FROM AxxxCxxx as v LEFT JOIN AxxxCxxxTxxx as trk "
+ "ON v.cxxx = trk.cxxx "
)
})
@Entity
@Table(name = "V_XXX")
public class AxxxCxxx implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "CXXX")
private String cxxx;
//getter, setter
}
ENTITY1類:
@Entity
@Table(name = "T_XXX")
public class AxxxCxxxTxxx extends Super implements
Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "CXXX")
private String cxxx;
//getter, setter
}
超類:
@MappedSuperclass
public abstract class Super implements Serializable {
private static final long serialVersionUID = -1413197336548058176L;
@Id
@Column(name = "TXXX", nullable = false)
private Integer txxx;
@Column(name = "IXXX", length = 15)
private String ixxx;
//getter, setter
}
當我嘗試執行NamedQuery,我得到這個例外:
Caused by: org.hibernate.HibernateException: Errors in named queries: find
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:504)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802)
... 26 more
org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join! [SELECT v.cxxx, trk.cxxx, trk.ixxx"
+ "FROM AxxxCxxx as v LEFT JOIN AxxxCxxxTxxx as trk "
+ "ON v.cxxx = trk.cxxx]
org.hibernate.hql.internal.ast.InvalidPathException: Invalid path: 'trk.ixxx'
at org.hibernate.hql.internal.ast.util.LiteralProcessor.lookupConstant(LiteralProcessor.java:114) ~[hibernate-core-5.0.5.Final.jar:5.0.5.Final]
請問,有人可以幫助我嗎?我怎樣才能解決視圖和表使用JPQL MappedSuperClass的左連接?