Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
3.x:
Hi,
I am facing a problem converting Hibernate objects (i.e. POJOs) to XML. I am using XStream to convert the objects into XML, but when I pass the object to XStream, it does'nt seem to find the actual fields but gives some other fields with even the class name suffixed with something like "EnhancerByCGLIB--411188b1 resolves-to="org.hibernate.proxy.SerializableProxy"
Here is an example of the XML output given by XStream
<edu.utd.eplan.business.objects.Facility--EnhancerByCGLIB--411188b1 resolves-to="org.hibernate.proxy.SerializableProxy">
<entityName>edu.utd.eplan.business.objects.Facility</entityName>
<persistentClass>edu.utd.eplan.business.objects.Facility</persistentClass>
<interfaces>
<java-class>org.hibernate.proxy.HibernateProxy</java-class>
</interfaces>
<id class="int">2</id>
<getIdentifierMethodClass>edu.utd.eplan.business.objects.Facility</getIdentifierMethodClass>
<setIdentifierMethodClass>edu.utd.eplan.business.objects.Facility</setIdentifierMethodClass>
<getIdentifierMethodName>getFacilityId</getIdentifierMethodName>
<setIdentifierMethodName>setFacilityId</setIdentifierMethodName>
<setIdentifierMethodParams>
<java-class>java.lang.Integer</java-class>
</setIdentifierMethodParams>
</edu.utd.eplan.business.objects.Facility--EnhancerByCGLIB--411188b1>
If I take a plain POJO without associating it with Hibernate Session i.e. I manually populate the fields, I get the correct XML output depicting the actual fields and their values.
I am using Hibernate framework with Spring framework. From the above output it seems that Hibernate is modifying the class through reflection. How can I get back the normal class or is there any other way to convert these objects to XML automatically (I am looking for available packages rather than writing my own code to do the conversion).
Thanks in advance
Phani