Does MOXy support non-string @XmlID in version 2.6.0?

不打扰是莪最后的温柔 提交于 2019-12-08 19:37:50

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/29564627/does-moxy-support-non-string-xmlid-in-version-2-6-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!