-->
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: In joined inheritance proxy have incorrect supertype.
PostPosted: Fri Jan 09, 2009 5:05 am 
Newbie

Joined: Fri Jan 09, 2009 4:31 am
Posts: 9
Hibernate 3.3.1.GA

Problem: In joined inheritance type hibernate proxy have incorrect supertype !

Billing billing = customer.getBilling();

boolean result = billing instanceof PersonBilling || billing instanceof CorporateBilling;

If billing object is not proxy(lazy=false) result is true (all ok);
But if billing object is proxy - result is false, and proxy supertype is Billing.

Why proxy has never supertype PersonBilling or CorporateBilling??

Customer.hbm.xml:
...
<class name="Customer" table="customers">
...
<many-to-one name="billing" column="billing_id" class="Billing" cascade="all" not-null="false" unique="true" />
...

Billing.hbm.xml:

<class name="Billing" table="billings">
...
<joined-subclass name="PersonBilling" table="person_billings">
...
<joined-subclass name="CorporateBilling" table="corporate_billings">
...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2009 5:14 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Hibernate is designed that way and it is due to Java's single inheritance model.
See http://www.hibernate.org/hib_docs/v3/reference/en-US/html_single/#performance-fetching-proxies
for a solution.
You should create interfaces for each subclass and use these as proxy.
Or disable proxies for these associations.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2009 5:37 am 
Newbie

Joined: Fri Jan 09, 2009 4:31 am
Posts: 9
Thanks!


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.