Hi,
I'm using hibernate through grails, and aksed this question on the grails mailing list, but no answers. Maybe somebody here can help me.
I'm trying to do the following sql query using gorm/hibernate criteria:
select k.*
from kandidaat as k
where exists ( select 1 from reactie where reactie_tekst = 'gereageerd' and kandidaat_id = k.id );
I'm using the isNotEmpty expression to handle the exists part like so:
isNotEmpty(
reactie {
eq("reactie_tekst","gereageerd")
}
)
In my log i can see that the where clause contains the following::
( ( reactie_tekst = 'gereageerd'
) and exists ( select 1 from reactie where id = id )
)
(simplyfied, there are actually more tables involved i the exists/isNotEmpty part.)
My question: how do i use the isNotEmpty with an embedded expression like equals?
Is this even possible with hibernate criteria? Can i have an expression on another table, which i do not want returned, without it being included with a join?
Thanks,
Andrej
|