-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to get the persistent object from a proxy
PostPosted: Mon Apr 26, 2004 3:00 pm 
Regular
Regular

Joined: Wed Nov 05, 2003 10:57 pm
Posts: 96
I have the following association:

A (*) ---- (1) B
B is abstract
B1 subclass of B
B2 subclass of B

when I do aB = A.getB(), I get B's proxy (which is expected)

aB is either of type B1 or B2. aB instanceof B1 or B2 returns false (expected with proxies).

My question is what is the best way to get the persistent object (B1 or B2) from the proxy so that dynamic casting works?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 3:16 pm 
Newbie

Joined: Thu Apr 22, 2004 3:21 pm
Posts: 15
I don't think this is a proxy issue. Try ***.getClass().isAssignableFrom(***)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 3:25 pm 
Regular
Regular

Joined: Wed Nov 05, 2003 10:57 pm
Posts: 96
aB is B's proxy (which is a subclass of B). B1 and B2 are subclasses of B. "isAssignableFrom" as "instanceof" would not work between aB and B1/B2.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 9:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate.getClass(foo) returns the underlying class

session.get(Bar.class, foo.getId()) will do a "typecast"


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