According to https://gist.github.com/VineetReynolds/5108580, JAXB Spec requires element annotated with @XmlID
to be a String
. This hasn't been enforced by MOXy in versions 2.5.x.
With version 2.6.0, however, it seems it's not supported anymore.
[Exception [EclipseLink-50016] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.JAXBException
Exception Description: Property [id] has an XmlID annotation but its type is not String.]**strong text**
Is this a wanted behavior, or an unwanted regression?
What is the right way to avoid such error when migrating from MOXy 2.5.x?
Is it to use @XmlJavaTypeAdapter
as described in this post Marshaling a long primitive type using JAXB, which also affects the way how the object itself (and its ID) gets serialized to JSON (e.g., id field of type Long
becomes a json string?
Yes, it is still supported. In 2.6.0 it is not supported by default, but must be enabled via @XmlIDExtension
annotation.
https://eclipse.org/eclipselink/releases/2.6.php
Just annotate given field with @XmlIDExtension
. It is also possible to specify system property org.eclipse.persistence.moxy.annotation.xml-id-extension
to override default behavior globally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With