You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently have a problem with using it in one of our project. We have an object model with a lot of cross referencing between the objects, that is seralized to XML. The cross referencing is implemented by IDREF(S) elements.
Per default JAXB is generating IDREF(S) elements as properties with type Object or List<Object>. In our case this is not convenient, since there are model constraints that define specific types for specific IDREFS. To avoid programming errors during serialization and to avoid unnecessary type checks and cast during deserialization, we have to customize the IDREF properties to specific types.
The only way to this (at least the one we found) is to create custom binding like this one:
And here starts the problem. The VecAbstractSlot itself is included in the schema and is generated by XJC, but at the time of parsing the Schema (and the Binding) XJC does not know that it generates the class. So FieldOutline.getRawType() is initialized with a com.sun.codemodel.JDirectClass .
In the plugin, this leads to duplicate methods in the Visitor interface, because one method is created for the generated class, and one method is created for the com.sun.codemodel.JDirectClass which actually point to the same class. Same applies to the Traverser.
Additionally, the DepthFirstTraverserImpl generates traversal for the IDREF(S) properties as well, which will result in endless looping.
From my point of view, there are two possible solutions:
Exclude the IDREF(S) properties from com.massfords.jaxb.ClassDiscoverer.discoverDirectClasses(Outline, Set<ClassOutline>). (I tried it and it works).
Double check, that there is no JDefinedClass with the same name as the JDirectClass.
I will try the second approach, as it seems more elegant and does not require interpretation of the CPropertyInfo.getSchemaComponent() and submit a pull request for either the first or the second approach.
THX in advance
The text was updated successfully, but these errors were encountered:
Thanks for your great plugin!
We currently have a problem with using it in one of our project. We have an object model with a lot of cross referencing between the objects, that is seralized to XML. The cross referencing is implemented by IDREF(S) elements.
see http://ecad-wiki.prostep.org/doku.php?id=specifications:vec:start for XSD and model documentation.
Per default JAXB is generating
IDREF
(S) elements as properties with typeObject
orList<Object>
. In our case this is not convenient, since there are model constraints that define specific types for specificIDREFS
. To avoid programming errors during serialization and to avoid unnecessary type checks and cast during deserialization, we have to customize theIDREF
properties to specific types.The only way to this (at least the one we found) is to create custom binding like this one:
And here starts the problem. The
VecAbstractSlot
itself is included in the schema and is generated by XJC, but at the time of parsing the Schema (and the Binding) XJC does not know that it generates the class. SoFieldOutline.getRawType()
is initialized with acom.sun.codemodel.JDirectClass
.In the plugin, this leads to duplicate methods in the
Visitor
interface, because one method is created for the generated class, and one method is created for thecom.sun.codemodel.JDirectClass
which actually point to the same class. Same applies to theTraverser
.Additionally, the
DepthFirstTraverserImpl
generates traversal for theIDREF(S)
properties as well, which will result in endless looping.From my point of view, there are two possible solutions:
com.massfords.jaxb.ClassDiscoverer.discoverDirectClasses(Outline, Set<ClassOutline>)
. (I tried it and it works).JDefinedClass
with the same name as theJDirectClass
.I will try the second approach, as it seems more elegant and does not require interpretation of the
CPropertyInfo.getSchemaComponent()
and submit a pull request for either the first or the second approach.THX in advance
The text was updated successfully, but these errors were encountered: