Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 216315 Details for
Bug 370573
Enhancement: support @XmlInverseReference with @XmlElementRef
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Propsed fix and tests
bug370573.patch (text/plain), 11.84 KB, created by
Matt MacIvor
on 2012-05-25 15:40:19 EDT
(
hide
)
Description:
Propsed fix and tests
Filename:
MIME Type:
Creator:
Matt MacIvor
Created:
2012-05-25 15:40:19 EDT
Size:
11.84 KB
patch
obsolete
>Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/XMLInverseReferenceMapping.java >=================================================================== >--- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/XMLInverseReferenceMapping.java (revision 11493) >+++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/XMLInverseReferenceMapping.java (working copy) >@@ -113,7 +113,7 @@ > for(XMLMapping next:nestedMappings) { > if(next instanceof XMLCompositeObjectMapping) { > XMLCompositeObjectMapping compositeMapping = ((XMLCompositeObjectMapping)next); >- if(compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) { >+ if(compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass() || this.getDescriptor().getJavaClass().isAssignableFrom(compositeMapping.getReferenceClass())) { > compositeMapping.setInverseReferenceMapping(this); > } > } else if(next instanceof XMLObjectReferenceMapping) { >@@ -131,7 +131,7 @@ > for(XMLMapping next:nestedMappings) { > if(next instanceof XMLCompositeCollectionMapping) { > XMLCompositeCollectionMapping compositeMapping = ((XMLCompositeCollectionMapping)next); >- if(compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) { >+ if(compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass() || this.getDescriptor().getJavaClass().isAssignableFrom(compositeMapping.getReferenceClass())) { > compositeMapping.setInverseReferenceMapping(this); > } > } else if(next instanceof XMLCollectionReferenceMapping) { >Index: moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.json >=================================================================== >--- moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.json (revision 0) >+++ moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.json (revision 0) >@@ -0,0 +1,2 @@ >+{"parent":{"child":[{}],"childSubclass":[{}]}} >+ >Index: moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.xml >=================================================================== >--- moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.xml (revision 0) >+++ moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.xml (revision 0) >@@ -0,0 +1,4 @@ >+<parent> >+ <child/> >+ <childSubclass/> >+</parent> >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/AnnotationsTestSuite.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/AnnotationsTestSuite.java (revision 11493) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/AnnotationsTestSuite.java (working copy) >@@ -14,6 +14,7 @@ > > import org.eclipse.persistence.testing.jaxb.annotations.xmlaccessmethods.XmlAccessMethodsTestCases; > import org.eclipse.persistence.testing.jaxb.annotations.xmlclassextractor.XmlClassExtractorTestCases; >+import org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference.InverseReferenceWithRefTestCases; > import org.eclipse.persistence.testing.jaxb.annotations.xmllocation.XmlLocationTestSuite; > import org.eclipse.persistence.testing.jaxb.annotations.xmlnametransformer.JAXBDefaultNameTransformerTestCases; > import org.eclipse.persistence.testing.jaxb.annotations.xmlnametransformer.classlevel.upper.JAXBClassLevelUpperNameTransformerTestCases; >@@ -84,6 +85,7 @@ > suite.addTest(XmlLocationTestSuite.suite()); > suite.addTest(org.eclipse.persistence.testing.jaxb.annotations.xmlvalue.XmlValueTestSuite.suite()); > suite.addTestSuite(CustomerTestCases.class); >+ suite.addTestSuite(InverseReferenceWithRefTestCases.class); > > return suite; > } >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/Child.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/Child.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/Child.java (revision 0) >@@ -0,0 +1,29 @@ >+/******************************************************************************* >+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Matt MacIvor - 2.4 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference; >+ >+import javax.xml.bind.annotation.XmlRootElement; >+ >+import org.eclipse.persistence.oxm.annotations.XmlInverseReference; >+ >+@XmlRootElement >+public class Child { >+ >+ @XmlInverseReference(mappedBy="children") >+ public Parent parent; >+ >+ public boolean equals(Object obj) { >+ Child child = (Child)obj; >+ return this.parent != null && child.parent != null; >+ } >+} >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/ChildSubclass.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/ChildSubclass.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/ChildSubclass.java (revision 0) >@@ -0,0 +1,20 @@ >+/******************************************************************************* >+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Matt MacIvor - 2.4 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference; >+ >+import javax.xml.bind.annotation.XmlRootElement; >+ >+@XmlRootElement >+public class ChildSubclass extends Child { >+ >+} >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/InverseReferenceWithRefTestCases.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/InverseReferenceWithRefTestCases.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/InverseReferenceWithRefTestCases.java (revision 0) >@@ -0,0 +1,45 @@ >+/******************************************************************************* >+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Matt MacIvor - 2.4 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.persistence.testing.jaxb.JAXBWithJSONTestCases; >+ >+public class InverseReferenceWithRefTestCases extends JAXBWithJSONTestCases { >+ private static final String XML_RESOURCE = "org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.xml"; >+ private static final String JSON_RESOURCE = "org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.json"; >+ >+ public InverseReferenceWithRefTestCases(String name) throws Exception { >+ super(name); >+ setClasses(new Class[]{ Parent.class, Child.class, ChildSubclass.class }); >+ setControlDocument(XML_RESOURCE); >+ setControlJSON(JSON_RESOURCE); >+ } >+ >+ public Object getControlObject() { >+ Parent parent = new Parent(); >+ parent.children = new ArrayList<Child>(); >+ >+ Child child = new Child(); >+ child.parent = parent; >+ parent.children.add(child); >+ >+ child = new ChildSubclass(); >+ child.parent = parent; >+ parent.children.add(child); >+ >+ return parent; >+ >+ } >+} >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/Parent.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/Parent.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/Parent.java (revision 0) >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Matt MacIvor - 2.4 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference; >+ >+import java.util.List; >+ >+import javax.xml.bind.annotation.XmlElementRef; >+import javax.xml.bind.annotation.XmlRootElement; >+ >+@XmlRootElement >+public class Parent { >+ >+ @XmlElementRef >+ public List<Child> children; >+ >+ public boolean equals(Object obj) { >+ Parent parent = (Parent)obj; >+ if(children.size() != parent.children.size()) { >+ return false; >+ } >+ for(int i = 0; i < children.size(); i++) { >+ Child child1 = children.get(i); >+ Child child2 = parent.children.get(i); >+ >+ if(!(child1.equals(child2))) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 370573
: 216315