-->
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.  [ 7 posts ] 
Author Message
 Post subject: Introspection returns CGLIB enhanced class, not original cla
PostPosted: Wed May 05, 2004 9:33 pm 
Beginner
Beginner

Joined: Sat Dec 06, 2003 5:38 pm
Posts: 27
Hi,

I am attempting to use Betwixt to serialize out my Hibernate objects. Unfortunantly, in my serialized file, the name of the class is the enhanced one via CGLIB:

Workorder$$EnhancerByCGLIB$$caeab843

what I really want is:

Workorder

How can I tell Hibernate to update/remove the dynamic proxy that was generated?

Alternatively, anyone recommend a xml <--> java serializer that doesn't require scheme/mapping files? I saw the Hibernate XmlDatabinder and the other ReverserXmlDataBinder in Jira, but they haven't been committed.

This is with Hibernate 2.1.

Eric


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 1:00 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I am not sure, but probably it is possible to use custom introspector for Betwixt.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 3:03 am 
Newbie

Joined: Tue Oct 21, 2003 1:25 pm
Posts: 14
Location: Los Angeles, CA
Check out: http://freshmeat.net/projects/jsx/

From the website: Java Serialization to XML (JSX) allows users to write and read any plain old Java object graph as XML data with one line of code. The data can be verified and manipulated with standard XML tools like DOM, JDOM, and XSLT. JSX automatically creates a file format/wire protocol for all Java objects, so that it is always up to date as the code evolves. It also provides the evolution techniques of Java Object Serialization for back-compatibility, and you can also modify the XML directly. Unlike databinders such as JAXB and Castor, no explicit mapping is required, and JSX works for all objects.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 6:51 am 
Beginner
Beginner

Joined: Sat Dec 06, 2003 5:38 pm
Posts: 27
I'll definitly take a look at it.. Do you think it will have any issues with the proxies? Or can I tweak it so that when it sees Workorder$$CGLIB proxy it knows that I really want a Workorder object?

Is there nothing like Session.makeNotProxy(proxiedObject) that would return the concrete implementation?
Eric


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 7:28 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
There is a public helper class in "proxy" package, see API docs I do not remember its name.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 04, 2004 8:24 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
I had the same problem found the helper class

net.sf.hibernate.proxy.HibernateProxyHelper.getClass(Object)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 08, 2005 7:21 pm 
Newbie

Joined: Tue Mar 08, 2005 7:11 pm
Posts: 9
Location: Sydney, Australia
I had this same problem and solved it using a customised Betwixt "ClassNormalizer", as follows:

public class HibernateProxyClassNormalizer extends ClassNormalizer {

public HibernateProxyClassNormalizer() {
super();
}

public Class getNormalizedClass(Object object) {
if(object == null) {
throw new IllegalArgumentException("Cannot get class for null object.");
}
else if(object instanceof net.sf.cglib.proxy.Factory) {
return normalize(object.getClass().getSuperclass());
}

else {
return normalize(object.getClass());
}
}
}

Then register this class with Betwixt via:

beanWriter.getXMLIntrospector().getConfiguration().setClassNormalizer(new HibernateProxyClassNormalizer());

Betwixt will then always be able to identify the correct class name for it's *.betwixt file lookup.


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