有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]
没办法了,自己想不出,只能来请各位看看指点指点我。谢谢!!!