Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 370573
Collapse All | Expand All

(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/XMLInverseReferenceMapping.java (-2 / +2 lines)
Lines 113-119 Link Here
113
            for(XMLMapping next:nestedMappings) {
113
            for(XMLMapping next:nestedMappings) {
114
                if(next instanceof XMLCompositeObjectMapping) {
114
                if(next instanceof XMLCompositeObjectMapping) {
115
                    XMLCompositeObjectMapping compositeMapping = ((XMLCompositeObjectMapping)next);
115
                    XMLCompositeObjectMapping compositeMapping = ((XMLCompositeObjectMapping)next);
116
                    if(compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) {
116
                    if(compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass() || this.getDescriptor().getJavaClass().isAssignableFrom(compositeMapping.getReferenceClass())) {
117
                        compositeMapping.setInverseReferenceMapping(this);
117
                        compositeMapping.setInverseReferenceMapping(this);
118
                    }
118
                    }
119
                } else if(next instanceof XMLObjectReferenceMapping) {
119
                } else if(next instanceof XMLObjectReferenceMapping) {
Lines 131-137 Link Here
131
            for(XMLMapping next:nestedMappings) {
131
            for(XMLMapping next:nestedMappings) {
132
                if(next instanceof XMLCompositeCollectionMapping) {
132
                if(next instanceof XMLCompositeCollectionMapping) {
133
                    XMLCompositeCollectionMapping compositeMapping = ((XMLCompositeCollectionMapping)next);
133
                    XMLCompositeCollectionMapping compositeMapping = ((XMLCompositeCollectionMapping)next);
134
                    if(compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) {
134
                    if(compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass() || this.getDescriptor().getJavaClass().isAssignableFrom(compositeMapping.getReferenceClass())) {
135
                        compositeMapping.setInverseReferenceMapping(this);
135
                        compositeMapping.setInverseReferenceMapping(this);
136
                    }
136
                    }
137
                } else if(next instanceof XMLCollectionReferenceMapping) {
137
                } else if(next instanceof XMLCollectionReferenceMapping) {
(-)moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.json (+2 lines)
Line 0 Link Here
1
{"parent":{"child":[{}],"childSubclass":[{}]}}
2
(-)moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.xml (+4 lines)
Line 0 Link Here
1
<parent>
2
   <child/>
3
   <childSubclass/>
4
</parent>
(-)moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/AnnotationsTestSuite.java (+2 lines)
Lines 14-19 Link Here
14
14
15
import org.eclipse.persistence.testing.jaxb.annotations.xmlaccessmethods.XmlAccessMethodsTestCases;
15
import org.eclipse.persistence.testing.jaxb.annotations.xmlaccessmethods.XmlAccessMethodsTestCases;
16
import org.eclipse.persistence.testing.jaxb.annotations.xmlclassextractor.XmlClassExtractorTestCases;
16
import org.eclipse.persistence.testing.jaxb.annotations.xmlclassextractor.XmlClassExtractorTestCases;
17
import org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference.InverseReferenceWithRefTestCases;
17
import org.eclipse.persistence.testing.jaxb.annotations.xmllocation.XmlLocationTestSuite;
18
import org.eclipse.persistence.testing.jaxb.annotations.xmllocation.XmlLocationTestSuite;
18
import org.eclipse.persistence.testing.jaxb.annotations.xmlnametransformer.JAXBDefaultNameTransformerTestCases;
19
import org.eclipse.persistence.testing.jaxb.annotations.xmlnametransformer.JAXBDefaultNameTransformerTestCases;
19
import org.eclipse.persistence.testing.jaxb.annotations.xmlnametransformer.classlevel.upper.JAXBClassLevelUpperNameTransformerTestCases;
20
import org.eclipse.persistence.testing.jaxb.annotations.xmlnametransformer.classlevel.upper.JAXBClassLevelUpperNameTransformerTestCases;
Lines 84-89 Link Here
84
        suite.addTest(XmlLocationTestSuite.suite());
85
        suite.addTest(XmlLocationTestSuite.suite());
85
        suite.addTest(org.eclipse.persistence.testing.jaxb.annotations.xmlvalue.XmlValueTestSuite.suite());
86
        suite.addTest(org.eclipse.persistence.testing.jaxb.annotations.xmlvalue.XmlValueTestSuite.suite());
86
        suite.addTestSuite(CustomerTestCases.class);
87
        suite.addTestSuite(CustomerTestCases.class);
88
        suite.addTestSuite(InverseReferenceWithRefTestCases.class);
87
89
88
        return suite;
90
        return suite;
89
    }
91
    }
(-)moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/Child.java (+29 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
5
 * which accompanies this distribution.
6
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7
 * and the Eclipse Distribution License is available at
8
 * http://www.eclipse.org/org/documents/edl-v10.php.
9
 *
10
 * Contributors:
11
 * Matt MacIvor - 2.4 - initial implementation
12
 ******************************************************************************/
13
package org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference;
14
15
import javax.xml.bind.annotation.XmlRootElement;
16
17
import org.eclipse.persistence.oxm.annotations.XmlInverseReference;
18
19
@XmlRootElement
20
public class Child {
21
    
22
    @XmlInverseReference(mappedBy="children")
23
    public Parent parent;
24
25
    public boolean equals(Object obj) {
26
        Child child = (Child)obj;
27
        return this.parent != null && child.parent != null;
28
    }    
29
}
(-)moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/ChildSubclass.java (+20 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
5
 * which accompanies this distribution.
6
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7
 * and the Eclipse Distribution License is available at
8
 * http://www.eclipse.org/org/documents/edl-v10.php.
9
 *
10
 * Contributors:
11
 * Matt MacIvor - 2.4 - initial implementation
12
 ******************************************************************************/
13
package org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference;
14
15
import javax.xml.bind.annotation.XmlRootElement;
16
17
@XmlRootElement
18
public class ChildSubclass extends Child {
19
    
20
}
(-)moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/InverseReferenceWithRefTestCases.java (+45 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
5
 * which accompanies this distribution.
6
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7
 * and the Eclipse Distribution License is available at
8
 * http://www.eclipse.org/org/documents/edl-v10.php.
9
 *
10
 * Contributors:
11
 * Matt MacIvor - 2.4 - initial implementation
12
 ******************************************************************************/
13
package org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference;
14
15
import java.util.ArrayList;
16
17
import org.eclipse.persistence.testing.jaxb.JAXBWithJSONTestCases;
18
19
public class InverseReferenceWithRefTestCases extends JAXBWithJSONTestCases {
20
    private static final String XML_RESOURCE =  "org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.xml";
21
    private static final String JSON_RESOURCE = "org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/parent.json";
22
23
    public InverseReferenceWithRefTestCases(String name) throws Exception {
24
        super(name);
25
        setClasses(new Class[]{ Parent.class, Child.class, ChildSubclass.class });
26
        setControlDocument(XML_RESOURCE);
27
        setControlJSON(JSON_RESOURCE);
28
    }
29
    
30
    public Object getControlObject() {
31
        Parent parent = new Parent();
32
        parent.children = new ArrayList<Child>();
33
        
34
        Child child = new Child();
35
        child.parent = parent;
36
        parent.children.add(child);
37
        
38
        child = new ChildSubclass();
39
        child.parent = parent;
40
        parent.children.add(child);
41
        
42
        return parent;
43
        
44
    }
45
}
(-)moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/annotations/xmlinversereference/Parent.java (+42 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
5
 * which accompanies this distribution.
6
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7
 * and the Eclipse Distribution License is available at
8
 * http://www.eclipse.org/org/documents/edl-v10.php.
9
 *
10
 * Contributors:
11
 * Matt MacIvor - 2.4 - initial implementation
12
 ******************************************************************************/
13
package org.eclipse.persistence.testing.jaxb.annotations.xmlinversereference;
14
15
import java.util.List;
16
17
import javax.xml.bind.annotation.XmlElementRef;
18
import javax.xml.bind.annotation.XmlRootElement;
19
20
@XmlRootElement
21
public class Parent {
22
    
23
    @XmlElementRef
24
    public List<Child> children;
25
    
26
    public boolean equals(Object obj) {
27
        Parent parent = (Parent)obj;
28
        if(children.size() != parent.children.size()) {
29
            return false;
30
        }
31
        for(int i = 0; i < children.size(); i++) {
32
            Child child1 = children.get(i);
33
            Child child2 = parent.children.get(i);
34
            
35
            if(!(child1.equals(child2))) {
36
                return false;
37
            }
38
        }
39
        return true;
40
    }
41
42
}

Return to bug 370573