-->
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.  [ 8 posts ] 
Author Message
 Post subject: Implicit and explicit polymorphism at runtime
PostPosted: Thu Apr 22, 2004 8:48 am 
Newbie

Joined: Thu Apr 22, 2004 8:33 am
Posts: 6
Hello,

I would like to know if there is any possibility to change the polymorphic behaviour of queries at runtime. To be more explicit, can I specify on a query that it has explicit or implicit polymorphism ? If it is not possible, how could I at some moment load only the properties of a root class (and instantiate this class), with implicit polymorphism set in the xml mapping file ?
I use a table per joined subclass strategy.

Thanks,
Florin Cremenescu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 4:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate has to do the join to know the concrete implementation of your class to be consistent with the OO aproach, so loading the proerties will not make much difference.
If you want to lazy load a part of your propertires, consider mapping you joined-subclass into a one-to-one

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 23, 2004 4:51 am 
Newbie

Joined: Thu Apr 22, 2004 8:33 am
Posts: 6
Hello,

I don't see the point. I think I don't understand well the difference between the implicit and the explicit polymorphism. I thought that by mapping a class with explicit polymorphism, a query using the name of that class will return instances of that class only, and not of its subclasses or joined-subclasses. If this is true, I don't understand your consistency concern with the OO aproach. And, again if this is true, why is it possible by specifying "explicit polymorphism" in the xml mapping file ?

Your solution consist in replacing all joined subclasses with one-to-one mappings ? It is not realistic, because a class could have several subclasses.

Loading only the super class part of a mapping is only a problem of performances, and I think that Hibernate should offer this possibility (by explicitly specifying it in a query), even if this breaks some OO.

Thanks for your help.

Florin Cremenescu


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 23, 2004 5:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Explicit polymorphism DOES NOT disable "mapped" polymorphism, expressed via <subclass>, <joined-subclass> or <union-subclass> mappings!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 23, 2004 12:31 pm 
Newbie

Joined: Thu Apr 22, 2004 8:33 am
Posts: 6
I begin to get the point. But there is no possibility to load only the super class part of a class (beyond the HQL specifying all the properties of the super class) ?

Thanks,
Florin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 29, 2004 3:27 am 
Newbie

Joined: Tue Sep 21, 2004 9:23 am
Posts: 5
I was wondering if someone has an anwser to Florin's last question.
Florin.Cremenescu wrote:
But there is no possibility to load only the super class part of a class (beyond the HQL specifying all the properties of the super class) ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 10:11 am 
Newbie

Joined: Wed Aug 18, 2004 9:45 am
Posts: 9
Location: Warsaw, Poland
Hi, I think this functionality would be very helpful. You can for example use "index-only" database fetching which is greatly faster than accessing database table by row id.

Is it possible to off polimorphism at all ? I don't need it everytime, moreover sometimes it's very inconvienient.

_________________
Tom Kucharski


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 22, 2008 2:11 am 
Newbie

Joined: Wed Sep 17, 2008 2:59 am
Posts: 10
emmanuel wrote:
Hibernate has to do the join to know the concrete implementation of your class to be consistent with the OO aproach, so loading the proerties will not make much difference.
If you want to lazy load a part of your propertires, consider mapping you joined-subclass into a one-to-one


Can't hibernate make an exception when using a discriminator ? Because the discriminator ALREADY tells Hibernate what subclass to instantiate without having to hit the table mapped to the subclass.

Thus, the behaviour that I was hoping for is that:

1) Hibernate checks the value of the discriminator column / formula, then creates an instance of the subclass as defined by the discriminator value ... BUT ... without loading the properties of the subclass. That is, it does not do a SELECT on the table mapped to the subclass.

2) When a get/set property of the subclass is then called, THEN Hibernate will do a SELECT on the table mapped to the subclass.

Reason for this is that, there are quite a few cases where we want the return a large list of entities from the parent class ... and we are not expecting to use any of the properties of the subclass, but there are some cases where we do.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.