Question

I have the following HQL

SELECT distinct demand  FROM MyDemand demand  
where demand in (   SELECT invd FROM MyDemand invd    
                      JOIN invd.MyDemandLine line    
                      JOIN line.Restr restr    
                where restr.Order=:order)

The problem is that the generated SQL is:

...........
 where
        (
            inventoryd0_.id, inventoryd0_.invNo
        ) in (
            select
                (inventoryd6_.id,
                inventoryd6_.invNo)
            from
                MyDemand inventoryd6_ 
................

The problem is that the sql fails at the "," from "inventoryd6_.id,inventoryd6_.invNo". If I remove the surroundings brackets, from SQL, everything works fine. I use Hibernate 3.?. Is this a bug in hibernate or I am doing something wrong?

Was it helpful?

Solution

I changed the query to:

SELECT distinct demand  FROM MyDemand demand  
where exists (   SELECT 'x' FROM MyDemand invd    
                      JOIN invd.MyDemandLine line    
                      JOIN line.Restr restr    
                where restr.Order=:order
                  and invd=demand)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top