HQL is generating incomplete 'cross join' on executeUpdate

前端 未结 1 1055
悲哀的现实
悲哀的现实 2021-02-13 14:08

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:16

    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)
提交回复
热议问题