users@jaxb.java.net

Property access of the generated code

From: Ben Gidley <bgidley_at_gmail.com>
Date: Fri, 27 Jan 2006 09:36:30 +0000

Hi,

I posted about this on the forum last week and it was suggested I follow up
to the mailing list.

I am trying to use Jaxb 2 to generate a from a complex XML schema a set of
classes which I will then extend and add additional behaviour too. The basic
idea is to allow us to use the XML classess in a GUI and not lose data when
users enter invalid data types. The application makes the user tidy up the
data type prior to export to XML and we have overridden the getXXX()
functions on the inherited classess.

This does not work with generated code - as it annotates the properties of
the parent class and it appears to read these directly via reflection. We
thought could solve this by setting the data back on the super class - but
this is complex and breaks if we also Hibernate the extended classes (due to
the CGLIB proxies).

I had a look into writing a plugin to 'move' the annotation from the
properties to the get method - as this would solve our problem. However I
can't see a way of removing the existing annotations from the code model -
only adding new ones.

At the moment by best plan is to using reflection to copy the child classes
data to a new copy of the parent - however this is a bit more complex that I
really wanted.

Do you have any ideas as to how I can tackle this?