-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Criteria question
PostPosted: Thu Nov 13, 2008 9:39 am 
Newbie

Joined: Thu Nov 13, 2008 9:05 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.