HQL is generating incomplete 'cross join' on executeUpdate

前端 未结 1 1945
旧时难觅i
旧时难觅i 2021-02-13 14:14

I am working on a grails project. I have following query that I am trying to execute

String CHECK_FOR_HIGH_TRADE_VOLUME_QUERY = \"Update LocationTrade lt set lt.         


        
1条回答
  •  长情又很酷
    2021-02-13 14:23

    The Hibernate documentation says:

    No join, either implicit or explicit, can be specified in a bulk HQL query. Sub-queries can be used in the where-clause, where the subqueries themselves may contain joins.

    lt.trade.volume is an implicit inner join between LocationTrade and Trade, so the query is invalid. You'll have to rewrite it to something like the following:

    update LocationTrade lt set lt.hasVeryHighVolume=true where lt.locationIndices=? 
    and lt.id in (
        select lt2.id from LocationTrade lt2 where lt2.trade.volume > 20000)
    

    Or you'll have to use a SQL query instead.

    0 讨论(0)
提交回复
热议问题