-->
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.  [ 3 posts ] 
Author Message
 Post subject: union of two hibernate criteria? Possible?
PostPosted: Thu Dec 14, 2006 12:32 pm 
Newbie

Joined: Thu Dec 14, 2006 12:23 pm
Posts: 6
Hibernate version: 3.1.2

Name and version of the database you are using: Oracle 10G


Hey there. I've exhausted all of my resources trying to figure this out. We have an application that allows a user to search for a specific set of users. The only problem here is that we are allowing the user to search two tables that do not have relationships, even though the criteria entered is the same.

Code:
listing table
----------------
listing_id
name
status
department
<other rows>

message_group table
---------------
group_number
group_name
<other rows>


When this was written in straight sql we would simply do
Code:
select listing_id, name, status, department
from listing where listing_id like :l_id_IN and name like :name_IN
UNION ALL
select group_number as listing_id, group_name as name, null as status, null as department
from message_group



Is it possible to do something like this using Criteria queries? I love the abstraction from the database that Criteria provides (not to mention the speed using projections, etc).


I've created two different criteria and am using a result transformer to populate a custom DTO.

thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 14, 2006 1:14 pm 
Newbie

Joined: Thu Dec 14, 2006 12:23 pm
Posts: 6
of course, hibernate does not support unions, but is this possible using a subquery?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 14, 2006 1:31 pm 
Beginner
Beginner

Joined: Thu Oct 12, 2006 6:19 pm
Posts: 34
Location: Guatemala
Hi, my two cents, it already was considered:
http://forum.hibernate.org/viewtopic.php?t=968111

I hope this helps

_________________
God is Love


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.