-->
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.  [ 1 post ] 
Author Message
 Post subject: Marshalling a Java object through Castor
PostPosted: Wed Dec 07, 2005 7:06 am 
Newbie

Joined: Wed Dec 07, 2005 6:56 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.