-->
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: Question Re: Use of Proxies and inheritance model
PostPosted: Sat Jun 09, 2007 4:14 pm 
Beginner
Beginner

Joined: Wed Jan 03, 2007 7:47 pm
Posts: 23
Location: Richardson, Texas
Hello All,

I am currently using Hibernate 3.2 with annotations and have a question regarding the use of proxies with entity inheritance.

I ran into unexpected behavior (although now realize I should have expected it) with the use of proxies and entity inheritance.

If I have inheritance B --> A and return an A proxy reference, I will get a ClassCastException since the generate class is an extension of A.

I found some good descriptions of this problem and understand now what is happening. My question is in regards to using interfaces for the proxies instead of concrete classes. Would this would eliminate the problem?

For example :

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@org.hibernate.annotations.Proxy(proxyClass = A.class)
@Table(name = "A")
public class AImpl implements A, Serializable

@Entity
@PrimaryKeyJoinColumn(name="key")
@org.hibernate.annotations.Proxy(proxyClass = B.class)
@Table(name = "B")
public class BImpl extends AImpl implements B, Serializable

I was curious as to how this would work differently. Would hibernate generate a proxy differently in this case? If a "BImpl" object was loaded
but an "A" proxy was returned, could this be cast to "B"?

Best Regards,
Kurt


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.