-->
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: Query to return only superclass
PostPosted: Mon Oct 04, 2010 1:06 am 
Newbie

Joined: Mon Sep 27, 2010 6:36 pm
Posts: 3
Hi,

I'm trying to query for a table where I only want superclass data without any subclass info. I have classes currently setup as

Class A { int x }

Class B extends A { int y }

With tables that look like

A
id=1, x=1
id=2, x=5

B
id=1, y=2

I'd like a query of table A to return ONLY id=1,x=1 and id=2,x=5, re: the superclass (A) data, without any subclass (B) data. I can't seem to find a way to run the query where table B is ignored without getting unknown column "y" errors. The main reasons not to include any subclass data is because 1- I only need the superclass data and 2- the app needs to be scalable.. B is just an example extension of A, but other subclasses (that I don't know about) will also be extending it.

I've searched the forums and found this problem show up several times, without any satisfactory result. Adding polymorphism=explicit to my mapping file has no effect.

TIA for any help.


Top
 Profile  
 
 Post subject: Re: Query to return only superclass
PostPosted: Wed Oct 06, 2010 4:21 pm 
Beginner
Beginner

Joined: Mon Mar 02, 2009 3:36 pm
Posts: 25
while preparing the SQL from ORM Query hibernate doesn't know that the object with you are lloking for is the instance of which subclass so hibernate prepares the SQL to join all the subclasses of the Parent class . I mean to say whenever you will try to fetch the parent class it will join all its sub class. If u want not to join multiple table use discriminator based approach .

Thanks,
Ganesh


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.