-->
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: How to only query root class using Inhertiance ?
PostPosted: Thu Feb 11, 2010 9:03 pm 
Newbie

Joined: Thu Nov 27, 2008 11:05 pm
Posts: 9
I have a simple inheritance model of "Property" and three subclasses "Residential", "Commercial", and "Land". I am using the JOINED inheritance strategy. For some reason when I just query the root "Property" class, Hibernate joins all the subclasses - which is what I don't want. I would like to perform an efficient search on just the root "Property" class/table. The code I have is below.... Is there an annotation that will allow me to query the root table and not join the subclasses?

Code:
@Entity
@Table(name = "Property")
@Inheritance(strategy = InheritanceType.JOINED)
public class Property implements Serializable {

   @Id
   @Column(name = "Uid")
   private Integer uid;

}



Code:
@Entity
@Table(name = "Residential")
public class Residential extends Property implements Serializable{

   @Column(name = "SqFt", length = 10)
   private String sqFt;

}


Code:
String query = "SELECT property from Property property";
Query q = em.createQuery(query);
list = (List<NtreisPrp>) q.getResultList();


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.