Dear all!
I found some postings talking about more advanced topics, so obviously people must have overcome what I am stuck with. Sorry if I overlooked the obvious, but I could not find any answer to me problem.
I am trying to use Castor to marshall a Java object that I loaded through Hibernate, like that:
Code:
Session session = HibernateUtil.currentSession();
myObjIf myObj = (MyObjBean)session.load(MyObjBean.class,new Integer(2));
Mapping mapping = new Mapping();
mapping.loadMapping("my-mapping.xml");
FileWriter writer = new FileWriter("test.xml");
Marshaller marshaller = new Marshaller(writer);
marshaller.setMapping(mapping);
marshaller.marshal(myObj);
session.close();
The problem is that myObj is not an instance of
MyObjBean
but of
MyObjBean$$EnhancerByCGLIB$$466e41f0
.
This means, by mapping for MyObjBean will not be found and observed. I therefore cannot specify any attributed as transient, which I would have to, to avoid lots of stuff to go to the XML that I don't want there. (I am basically marshalling the whole content of the DB otherwise.)
I cannot change the Castor mapping to MyObjBean$$EnhancerByCGLIB$$466e41f0 either, as the last part obviously is an instance number that is going to change at any run.
Any pointers in any direction would be helpful.
I don't think the XML features of Hibernate are what I want, especially as this would mean additional attributed in the mappings.
Regards,
Torsten