-->
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: querying for superclass properties only
PostPosted: Sun Jan 01, 2012 5:26 pm 
Newbie

Joined: Fri Dec 30, 2011 6:45 pm
Posts: 1
Hello,

I'm trying to use joined inheritance mapping strategy and despite its name I'd like to avoid joins in some scenarios when querying. In my use case I need only superclass properties most of the time. I need subclass properties only to display an item's details. Yet hibernate will always include joins for all subclasses in select queries. I understand that this is required in order to infer type information when no discriminator column is used. But when discriminator column is available then it should be possible to only select properties of a superclass and select from subclass table only when needed (for example when subclass properties are assessed). I searched on this forum and seen other people asking about the same problem and it appears that what I'm looking for is not available in Hibernate today.

Do you think that some kind of lazy loading of subclass properties makes sense?

What alternative solutions do you use today?

Regards,
Piotr


Top
 Profile  
 
 Post subject: Re: querying for superclass properties only
PostPosted: Thu Mar 21, 2013 10:31 am 
Newbie

Joined: Thu Mar 21, 2013 10:17 am
Posts: 1
Hi,

You can try use two entities classes referring the same table (i.e. using @Table annotation to specify the target table name) and share the same fields (put them into the base class to avoid the duplication). One of these entities (call it 'Heavy' ) can be marked with both @Entity and @Inheritance(strategy=Join) annotations, the other one (call it 'Light') will have only @Entity. When you need to fetch all children's data, use 'Heavy'. In case you do not need joins, use 'Light'. I did not try that but seems it just might work.


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.