-->
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: Load Only Super Class
PostPosted: Wed Mar 04, 2015 3:52 am 
Newbie

Joined: Wed Mar 04, 2015 3:39 am
Posts: 1
Hi all,
I have a DB mapped to Java objects using Hibernate.
Some of the objects are inherited from the others, and the mapping is using joined strategy:
I have an Attribute class mapped to attributes table, and it is extended by AttributeColor class mapped (joined strategy) to attributes_colors table.
This means that if I have 5 Attribute instances and 2 AttributeColor instances, the attributes table will contain 7 rows.
My question is how can I query only Attribute instances and not AttributeColor instances? Meaning I want to query a total of 5 objects.
Using a query "from Attribute" will return all the seven rows.
Solutions on line suggest ways to query all the rows (total of 7), but all as Attribute instances. This is not exactly what I want. I need to omit all the rows which are joined to child tables.

One option is to use a discriminator column, but one of the reasons I am using joined strategy is to avoid this.
Is there another option to create such query?

Thanks,
Guy


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.