有5张表:
A表:id,bid
B表:id,cid
C表:id
D表:id,cid
E表:id,did B、D是C的子表,A是B的子表,E是D的子表。
全部左连接,要求顺序:A-B-C-D-E 可以反着:E-D-C-B-A,没什么区别,但是不能乱只能这两种。
HQL语句怎么写?我自己写的第一条:
from A a left join B b on a.bid = b.id
left join C c on b.cid = c.id
left join D d on d.cid = c.id
left join E e on e.did = d.id 这条语句提示on关键字有错。 第二条:
from A a left join B b
left join C c
left join D d
left join E e
where a.bid = b.id and b.cid = c.id and d.cid = c.id and e.did = d.id 错误:
org.springframework.orm.hibernate3.HibernateQueryException: Path expected for join! [ from com.newer.business.pojo.MProcedureModule mpme left join MProcedure mpe left join MManufacture mme left join MProceduring mpg left join MProcedureModuling mpmg where mpme.MProcedure.id = mpe.id and mpe.MManufacture.id = mme.id and mpg.MManufacture.id = mme.id and mpmg.MProceduring.id = mpg.id and mme.id = 1]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [ from com.newer.business.pojo.MProcedureModule mpme left join MProcedure mpe left join MManufacture mme left join MProceduring mpg left join MProcedureModuling mpmg where mpme.MProcedure.id = mpe.id and mpe.MManufacture.id = mme.id and mpg.MManufacture.id = mme.id and mpmg.MProceduring.id = mpg.id and mme.id = 1]
Caused by:
org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [ from com.newer.business.pojo.MProcedureModule mpme left join MProcedure mpe left join MManufacture mme left join MProceduring mpg left join MProcedureModuling mpmg where mpme.MProcedure.id = mpe.id and mpe.MManufacture.id = mme.id and mpg.MManufacture.id = mme.id and mpmg.MProceduring.id = mpg.id and mme.id = 1] 没办法了,自己想不出,只能来请各位看看指点指点我。谢谢!!!
A表:id,bid
B表:id,cid
C表:id
D表:id,cid
E表:id,did B、D是C的子表,A是B的子表,E是D的子表。
全部左连接,要求顺序:A-B-C-D-E 可以反着:E-D-C-B-A,没什么区别,但是不能乱只能这两种。
HQL语句怎么写?我自己写的第一条:
from A a left join B b on a.bid = b.id
left join C c on b.cid = c.id
left join D d on d.cid = c.id
left join E e on e.did = d.id 这条语句提示on关键字有错。 第二条:
from A a left join B b
left join C c
left join D d
left join E e
where a.bid = b.id and b.cid = c.id and d.cid = c.id and e.did = d.id 错误:
org.springframework.orm.hibernate3.HibernateQueryException: Path expected for join! [ from com.newer.business.pojo.MProcedureModule mpme left join MProcedure mpe left join MManufacture mme left join MProceduring mpg left join MProcedureModuling mpmg where mpme.MProcedure.id = mpe.id and mpe.MManufacture.id = mme.id and mpg.MManufacture.id = mme.id and mpmg.MProceduring.id = mpg.id and mme.id = 1]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [ from com.newer.business.pojo.MProcedureModule mpme left join MProcedure mpe left join MManufacture mme left join MProceduring mpg left join MProcedureModuling mpmg where mpme.MProcedure.id = mpe.id and mpe.MManufacture.id = mme.id and mpg.MManufacture.id = mme.id and mpmg.MProceduring.id = mpg.id and mme.id = 1]
Caused by:
org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [ from com.newer.business.pojo.MProcedureModule mpme left join MProcedure mpe left join MManufacture mme left join MProceduring mpg left join MProcedureModuling mpmg where mpme.MProcedure.id = mpe.id and mpe.MManufacture.id = mme.id and mpg.MManufacture.id = mme.id and mpmg.MProceduring.id = mpg.id and mme.id = 1] 没办法了,自己想不出,只能来请各位看看指点指点我。谢谢!!!
解决方案 »
- hibernate.reveng.xml的作用什么
- 求助
- 来看看我们公司面试题------------------------
- 数据集得不到列的值
- 为什么Hibernate没有返回java.util.Date类型,却返回了java.sql.Date类型
- 又是prototype window的问题。急急急!
- java能访问MS的MSMQ吗?在百度搜索一下,没发现相关资料。多谢指教!
- 如何将一个double的数据至少保留九位小数
- 关于weblogic免费试用的问题?急!
- 高分求助!关于Swing方面的问题
- Servlet.service() for servlet action threw exception
- J2EE Specification Level 是什么,有什么作用?
因为取的结果比较特殊的原因,延迟加载解决不了。
......
前面加上selecct 查询字段 from A a left join B b on a.bid = b.id ...try it...
from a left join a.b
left join a.b.c
left join a.b.c.d
left join a.b.c.e要不你就用native sql。
2.然后写下面的这条语句
from A a left join B b
left join C c
left join D d
left join E e