{"action":"opened","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-modules-base/issues/46","repository_url":"https://api.github.com/repos/FasterXML/jackson-modules-base","labels_url":"https://api.github.com/repos/FasterXML/jackson-modules-base/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-modules-base/issues/46/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-modules-base/issues/46/events","html_url":"https://github.com/FasterXML/jackson-modules-base/issues/46","id":327370717,"number":46,"title":"JaxbAnnotationModule Incorrectly Serializes Object as Ref Only In some Cases","user":{"login":"GonenI","id":39408293,"avatar_url":"https://avatars3.githubusercontent.com/u/39408293?v=4","gravatar_id":"","url":"https://api.github.com/users/GonenI","html_url":"https://github.com/GonenI","followers_url":"https://api.github.com/users/GonenI/followers","following_url":"https://api.github.com/users/GonenI/following{/other_user}","gists_url":"https://api.github.com/users/GonenI/gists{/gist_id}","starred_url":"https://api.github.com/users/GonenI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GonenI/subscriptions","organizations_url":"https://api.github.com/users/GonenI/orgs","repos_url":"https://api.github.com/users/GonenI/repos","events_url":"https://api.github.com/users/GonenI/events{/privacy}","received_events_url":"https://api.github.com/users/GonenI/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-29T15:23:22Z","updated_at":"2018-05-29T15:23:22Z","closed_at":null,"author_association":"NONE","body":"When using Jackson with JaxbAnnotationModule , if objects with similar ids appears in two different fields of an outer object , it is sometimes incorrectly serialized as a ref only, instead of as a full object\r\nCase 1:\r\n The Inner object class has both @XMLID and @XMLElement properties\r\n One of the inner objects appear in a list field of the outer object, and another in another field\r\n Unit Test to show problem:\r\n\r\nclass HasID\r\n{\r\n\tString id;\r\n\tString name;\r\n    @XmlID \r\n    @XmlElement\r\n    public String getId() {\r\n        return id;\r\n    }\r\n    @XmlElement\r\n    public String getName() { return name; }\r\n}\r\n\r\n@XmlRootElement\r\nclass HasIDList\r\n{\r\n\tList<HasID> elements = null;\r\n    @XmlElement\r\n    public List<HasID> getElements( ) { return elements; }\r\n    public void setElements( List<HasID> elements ) { this.elements = elements; }\r\n    HasID parent;\r\n    @XmlElement \r\n    public HasID getParent() { return parent; }\r\n}\r\n\r\n\r\npublic class SerializeAsFullObjectTest{\r\n\r\n\t@Test\r\n\tpublic void test() throws Exception {\r\n\t\tObjectMapper mapper = new ObjectMapper();\r\n\t\tJaxbAnnotationModule jaxbAnnotationModule = new JaxbAnnotationModule();\r\n\t\tmapper.registerModule(jaxbAnnotationModule);\r\n\r\n\t\tHasID hasID = new HasID();   \r\n\t\thasID.id = \"1\"; hasID.name=\"name1\";\r\n\t\tHasID hasID2 = new HasID();\r\n\t\thasID2.id = \"1\"; hasID2.name=\"name1\";\r\n\t\t\r\n\t\tHasIDList idList = new HasIDList();\r\n\t\tidList.setElements(Arrays.asList(hasID,hasID2));\r\n\t\tidList.parent = hasID2;\r\n\t\t\r\n\t\tAssert.assertEquals(\"{\\\"elements\\\":[{\\\"id\\\":\\\"1\\\",\\\"name\\\":\\\"name1\\\"},{\\\"id\\\":\\\"1\\\",\\\"name\\\":\\\"name1\\\"}],\\\"parent\\\":{\\\"id\\\":\\\"1\\\",\\\"name\\\":\\\"name1\\\"}}\", mapper.writeValueAsString(idList));\r\n\t}\r\n}\r\n \r\nThe problem only appears when\r\n 1) Using JaxbAnnotations, with @XmlID and ( @XmlElement or @XmlAttribute)\r\n\r\nThis is a real ( non academic ) problem in a current production project."}}
{"actor":{"display_login":"GonenI"}}