英文:
JOIN with multiple OR in HQL
问题
以下是一个带有多个连接和条件的SQL查询,可以得到所需的输出。我想将下面的查询转换为HQL。
select c from Customer c
join CustomerGeoRel cg on c.id = cg.customerId
join Geography g on cg.geoId = g.id
join GeoGeoHierarchy gghCluster on g.id = gghCluster.geoId
join GeoGeoHierarchy gghDivision on gghCluster.geoId = gghDivision.parentGeoId
join RoleDataRel rdr on gghCluster.geoId = rdr.permissionDataId or
gghDivision.parentGeoId = rdr.permissionDataId or
g.id = rdr.permissionDataId
英文:
Below is a SQL query with multiple joins and conditions which gives the desired output, I want to convert the below query to HQL
select * from customer c
join customer_geo_rel cg on c.id=cg.customer_id
join geography g on cg.geo_id=g.id
join geo_geo_hierarchy gghCluster on g.id = gghCluster.geo_id
join geo_geo_hierarchy gghDivision on gghCluster.geo_id = gghDivision.parent_geo_id
join role_data_rel rdr on gghCluster.geo_id = rdr.permission_data_id OR
gghDivision.parent_geo_id = rdr.permission_data_id OR
g.id=rdr.permission_data_id
答案1
得分: 0
什么是问题?HQL支持用于连接的ON子句,如果您使用的是非常旧的Hibernate版本,您可以使用类似于.. join g.roleDataRelList rds on ...
的WITH子句。
英文:
What's the problem? HQL supports the ON clause for joins and if you use a very old version of Hibernate, you can use the WITH clause like e.g. .. join g.roleDataRelList rds on ...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论