-->
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.  [ 2 posts ] 
Author Message
 Post subject: Help with HibernateCriteria
PostPosted: Wed Jun 25, 2008 5:37 pm 
Newbie

Joined: Wed Jun 25, 2008 5:26 pm
Posts: 3
Consider this case …

Table T1 --> id, name

Table T2 --> id, name, desc, object_instance_id

These two tables T1 and T2 are not associated …

Only T2’s column object_instance_id is populated with T1.id …

There is no relationship between T1 and T2 in terms of database …


I need something as follows …

Select * from T1, T2 where T1.name=’something’ and T1.id = T2.object_instance_id and T2.name=’<some value>’


Does anyone know how to do this efficiently in terms of hibernate criteria?

Please send me the code if you think this can be done in terms of HibernateCriteria …


Thanks,
Suchandra


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 4:16 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

The criteria API implies that there is a association between the entities you want to join. This is not the case in your example. You basically want to do a theta join within the criteria API. I believe this is only possible with the HQL using pretty much exactly the query in your example. It should return a list of Object pairs (Object[2]).

--Hardy


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

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.