-->
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.  [ 5 posts ] 
Author Message
 Post subject: finding the classname when using proxies?
PostPosted: Tue Feb 24, 2004 9:05 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:02 pm
Posts: 27
Location: New York, NY
hi-

Im sure there is some simple way around this, but I can't figure it out. Basically, I want to find the className of an object dynamically, and use the following:

object.getClass().getName()...

This works normally of course, but when using proxies, the name returned is not what you would expect.

Is there any way around this issue when using proxies?

Thanks!
Brandon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2004 10:07 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Have you tried the Hibernate.getClass() method?

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 8:17 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
or
Code:
super.getClass().getName();
if you don't want the proxy to be initialized

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 01, 2004 5:24 pm 
Beginner
Beginner

Joined: Fri Oct 10, 2003 10:12 am
Posts: 39
Quote:
or super.getClass().getName();
if you don't want the proxy to be initialized


how does this work? won't it just return the proxied class and not the true class taking into accout subclasses?
cam


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 4:02 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Code:
Class getPersistentClass(Object persistentObject ){
  if(obj instanceof Factory){ //implements cglib interface
    return obj.getClass().getSuperlass();
  }else{
    return obj.getClass();
  }

}


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