-->
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.  [ 3 posts ] 
Author Message
 Post subject: Inheritance design pattern and Hibernate
PostPosted: Tue Nov 11, 2003 10:25 am 
Beginner
Beginner

Joined: Thu Sep 25, 2003 10:30 am
Posts: 23
Location: india
I got this problem. I have one class(parent) which is extended by other class (child).
When I query the parent the child gets queried with the outer join.
How do I prevent this?
I went through the documentation. And tried every permutation and combination with proxies and discriminator value. But with no result.
I don't understand how the discriminator-value and proxy works.
I am using Hibernate 2.0.3.


The mapping file is something like this.

<hibernate-mapping>
<class name="org.presci.extender.Parent" table="tbl_parent" proxy="org.presci.extender.Parent" discriminator-value="org.presci.extender.Parent">
<id name="id">
<generator class="identity"/>
</id>
<property name="fname"/>
<property name="lname"/>


<joined-subclass name="org.presci.extender.Child" table="tbl_child" proxy="org.presci.extender.Child">
<key column="parentid"/>
<property name="address"/>
</joined-subclass>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2003 10:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can't proxy a subclass in Hibernate. And when you query an instance of the parent, you have no way of knowing that it is not an instance of the subclass.


Try to remodel this as a one-to-one association if thats what it really is (looks like it).


Top
 Profile  
 
 Post subject: Inheritance design pattern and Hibernate
PostPosted: Thu Nov 13, 2003 2:37 am 
Beginner
Beginner

Joined: Thu Sep 25, 2003 10:30 am
Posts: 23
Location: india
Thank you sir,
I really appreciate.

The project doesn't requires delegation design pattern.
The query being generated works really fantastic when I query any of the child.
The problem is when I query the parent. I got this two childs which are inherited from the same parent. This two childs also gets queried but I don't want this to happen. I want something like lazy binding on the childs.

I really appreciate for your time. Hope you can help me.
Thanks
regards & respect
prasad chandrasekaran


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