tags:

views:

674

answers:

2

I have some jaxb objects (instantiated from code generated from xsd by jaxb) that I need to clone. The Jaxb class does not appear to provide an interface for doing this easily. I can not hand edit the class and can not extend it - so I need to create a helper/utility method to do this. What is the best approach?

+3  A: 

Given the purpose of JAXB, I think the easiest way would be to marshall your object to XML and unmarshall it back.

Lots more discussions on Google.

JAXB FAQ suggests beanlib.

There's also some discussion (as well as a link to download) of a Cloneable plugin under jaxb2-commons, although I can't find any reference on the project page.

ykaganovich
Yes - marshall-to-unmarshall worked perfectly. I am awarding you the answer. Of course - there is a time hit to this over serialization - but since it can't be serialized there are not lot of other choices besides reflection.
Shane C. Mason
A: 

btw duffymo, Shane is correct when he uses the word "effect". "affect" is the word used when talking about how something impacts something mentally. This is where the term Affective disorder comes from.

You learn something new everyday.

Dr Sigmund Freud