-->
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: Criteria Using an Interface
PostPosted: Thu Oct 08, 2009 3:08 pm 
Newbie

Joined: Mon Feb 23, 2009 11:16 am
Posts: 17
So I'm doing the following:
Code:
DetachedCriteria criteria = DetachedCriteria.forClass(Instrument.class);


Where Instrument.class is an interface which is implemented by a @MappedSuperclass abstract class which is itself extended by two @Entity classes.

So now if I do a search against this criteria will it simply return all objects of type Instrument.class from all tables that are created by its subclasses?

I guess that's what I see happening and am wondering if this is proper use of Hibernate or if I'm relying on "undefined" properties of Hibernate.

Thanks.


Top
 Profile  
 
 Post subject: Re: Criteria Using an Interface
PostPosted: Thu Oct 29, 2009 4:21 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Hibernate supports polymorphic querying on any object that ends up being mapped.

for giggles, try doing a select on Object.class and it will load up every entity in every table in your db.

_________________
Some people are like Slinkies - not really good for anything, but you still can't help but smile when you see one tumble down the stairs.


Top
 Profile  
 
 Post subject: Re: Criteria Using an Interface
PostPosted: Mon Nov 09, 2009 4:49 pm 
Newbie

Joined: Mon Feb 23, 2009 11:16 am
Posts: 17
Thank you.


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.