Skip to content

Commit

Permalink
fix sdo test failures
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Sep 6, 2021
1 parent 1556cd9 commit d801704
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping;
import org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping;
import org.eclipse.persistence.oxm.mappings.XMLDirectMapping;
import org.eclipse.persistence.oxm.mappings.XMLInverseReferenceMapping;
import org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping;
import org.eclipse.persistence.sdo.SDOChangeSummary;
import org.eclipse.persistence.sdo.SDODataObject;
Expand Down Expand Up @@ -195,8 +196,9 @@ public void setDeclaredProperty(int propertyIndex, Object value) {
// OLD VALUE
if (mapping.isAbstractCompositeObjectMapping()) {
XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
if (oldValue != null && compositeMapping.getInverseReferenceMapping().getAttributeAccessor() != null) {
compositeMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(oldValue, null);
XMLInverseReferenceMapping inverseReferenceMapping = compositeMapping.getInverseReferenceMapping();
if (oldValue != null && inverseReferenceMapping != null && inverseReferenceMapping.getAttributeAccessor() != null) {
inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(oldValue, null);
}
}

Expand All @@ -205,8 +207,9 @@ public void setDeclaredProperty(int propertyIndex, Object value) {
mapping.getAttributeAccessor().setAttributeValueInObject(entity, newValue);
if (mapping.isAbstractCompositeObjectMapping()) {
XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
if (value != null && compositeMapping.getInverseReferenceMapping().getAttributeAccessor() != null) {
compositeMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(newValue, entity);
XMLInverseReferenceMapping inverseReferenceMapping = compositeMapping.getInverseReferenceMapping();
if (value != null && inverseReferenceMapping != null && inverseReferenceMapping.getAttributeAccessor() != null) {
inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(newValue, entity);
}
}
}
Expand Down Expand Up @@ -250,15 +253,16 @@ public void unsetDeclaredProperty(int propertyIndex) {
// OLD VALUE
if (mapping.isAbstractCompositeCollectionMapping()) {
XMLCompositeCollectionMapping compositeMapping = (XMLCompositeCollectionMapping) mapping;
if (compositeMapping.getInverseReferenceMapping().getAttributeAccessor() != null) {
XMLInverseReferenceMapping inverseReferenceMapping = compositeMapping.getInverseReferenceMapping();
if (inverseReferenceMapping != null && inverseReferenceMapping.getAttributeAccessor() != null) {

Object oldContainer = mapping.getAttributeValueFromObject(entity);
if (oldContainer != null) {
AbstractSession session = ((JAXBContext) jaxbHelperContext.getJAXBContext()).getXMLContext().getSession(entity);
Object iterator = containerPolicy.iteratorFor(oldContainer);
while (containerPolicy.hasNext(iterator)) {
Object oldValue = containerPolicy.next(iterator, session);
compositeMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(oldValue, null);
inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(oldValue, null);
}
}
}
Expand All @@ -272,9 +276,10 @@ public void unsetDeclaredProperty(int propertyIndex) {
Object oldValue = mapping.getAttributeAccessor().getAttributeValueFromObject(entity);
if (mapping.isAbstractCompositeObjectMapping()) {
XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
if (compositeMapping.getInverseReferenceMapping().getAttributeAccessor() != null) {
final XMLInverseReferenceMapping inverseReferenceMapping = compositeMapping.getInverseReferenceMapping();
if (inverseReferenceMapping != null && inverseReferenceMapping.getAttributeAccessor() != null) {
if (oldValue != null) {
compositeMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(oldValue, null);
inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(oldValue, null);
}
}
}
Expand Down

0 comments on commit d801704

Please sign in to comment.