-->
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: How to query across subclasses?
PostPosted: Tue Jun 06, 2006 2:48 pm 
Beginner
Beginner

Joined: Tue May 23, 2006 10:53 am
Posts: 24
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1.3

Hi,

I used table-per-class-hierarchy strategy to map one of my tables. The mapping file is like below:

<class name="parent" ...>
<subclass name="child1" .../>
<subclass name="child2" .../>
</class>

How do I support queries that across the subclasses like:

select * from child1 where exists(select * from child2 where child2.prop =...);

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 06, 2006 3:58 pm 
Beginner
Beginner

Joined: Tue May 23, 2006 10:53 am
Posts: 24
I got it by searching through Hibernate documentation.

Use DetachedCriteria to create subQuery.

Then use
Criteria.add(Subqueries.exists(DetachedCriteria))
to append the condition.


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.