Hibernate可以做到这一点吗?
select A.something, B.something, C.something, D.something , E.* from A LEFT OUTER JOIN B on A.id = B.id_fk LEFT OUTER JOIN C ON B.id = C.id_fk LEFT OUTER JOIN D ON C.id = D.id_fk LEFT OUTER JOIN E ON A.abc = E.abc;
该查询在SQL中工作正常,但在Hibernate中给出以下异常:
org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found '*' near line 1
您不需要“ ”。hibernate正在旋转对象,对于指向SQL中的列没有意义。当您需要E时,它将变成E对象。
从E中选择E
这是HQL SELECT * FROM E
SELECT * FROM E
当您调用session.createQuery()时,甚至“ FROM E”也可以使用。