-->
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: Performing criteria query on two unrelated tables
PostPosted: Sun Oct 07, 2007 8:19 am 
Newbie

Joined: Sat Jan 20, 2007 10:29 am
Posts: 8
I would need to perform a criteria query on two unrelated tables (entities) that, if I was using HQL instead of the Criteria API, I would query using something like this:

Code:
SELECT <field_list> FROM entity1,entity2 WHERE entity1.a_field=entity2.another_field AND <extra_conditions>


It must be noted that that a_field and another_field are not primary/foreign keys of these tables. Additionally, since one of the tables is updated by an external application and has a fixed structure, I cannot add a foreign key to it.

That's why I cannot join the two entities using createCriteria() or createAlias(). On the other hand the Criteria API doesn't seem to support more than one root entity, so I cannot directly translate the above HQL query into a sequence of Criteria API calls. Nevertheless, I would like to be able to use the Criteria API instead of HQL because the <extra_conditions> mentioned in the HQL query above are variable, depending on user input.

Do I have any chance of using the Criteria API under these circumstances?

Thanks in advance.


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.