Support @XmlID, @XmlIDREF #2

Closed
tatu-at-salesforce opened this Issue Mar 12, 2012 · 2 comments

Projects

None yet

2 participants

@tatu-at-salesforce
Contributor

(note: re-creation of [https://jira.codehaus.org/browse/JACKSON-442])


Now that Jackson 2.0 supports Object Identity, with the new '@XmlIdentityInfo' annotation (and all the machinery needed to support it), we could finally tackle these 2 tricky JAXB annotations.

@tatu-at-salesforce
Contributor

(copying the original description)


Hello, is it possible during serialization to support these annotations to handle unidirectional reference ?

Folder.java
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Folder {

@XmlID
private String id;

@XmlIDREF
@XmlElement(name = "parentId")
private Folder parent;

}
which would generate

folder.json
{
"folder": {
"id": "1",
"parentId": "6"
}
}

@cowtowncoder
Member

Turned out that supporting this annotation was not all that difficult: although JAXB concept is little bit different from the way Jackson does it, things match well enough so that simple cases work (as per unit test). More testing would be helpful of course; but the base implementation is checked in now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment