Iterator<DatabaseMapping> ormMappings = ormDescriptor.getMappings().iterator();
while(ormMappings.hasNext()) {
DatabaseMapping ormMapping = ormMappings.next();
Mapping oxmMapping = (Mapping) oxmDescriptor.getMappingForAttributeName(ormMapping.getAttributeName());
if(oxmMapping != null) {
CoreAttributeAccessor oxmAccessor = oxmMapping.getAttributeAccessor();
OrmAttributeAccessor newAccessor = new OrmAttributeAccessor(ormMapping.getAttributeAccessor(), oxmAccessor);
if(ormMapping.isOneToOneMapping() && ((OneToOneMapping)ormMapping).usesIndirection()) {
newAccessor.setValueHolderProperty(true);
}
newAccessor.setChangeTracking(ormDescriptor.getObjectChangePolicy().isAttributeChangeTrackingPolicy());
oxmMapping.setAttributeAccessor(newAccessor);
//check to see if we need to deal with containerAccessor
CoreAttributeAccessor containerAccessor = null;
Class containerClass = null;
if(oxmMapping.isAbstractCompositeObjectMapping()) {
containerAccessor = ((CompositeObjectMapping)oxmMapping).getInverseReferenceMapping().getAttributeAccessor();
containerClass = ((CompositeObjectMapping)oxmMapping).getReferenceClass();
} else if(oxmMapping.isAbstractCompositeCollectionMapping()) {
containerAccessor = ((CompositeCollectionMapping)oxmMapping).getInverseReferenceMapping().getAttributeAccessor();
containerClass = ((CompositeCollectionMapping)oxmMapping).getReferenceClass();
}
if(containerAccessor != null) {
ClassDescriptor containerDescriptor = ormSession.getDescriptor(containerClass);
if(containerDescriptor != null) {
DatabaseMapping ormContainerMapping = containerDescriptor.getMappingForAttributeName(containerAccessor.getAttributeName());
if(ormContainerMapping != null) {
//Check for indirection on the container mapping
OrmAttributeAccessor ormAccessor = new OrmAttributeAccessor(ormContainerMapping.getAttributeAccessor(), containerAccessor);
ormAccessor.setChangeTracking(containerDescriptor.getObjectChangePolicy().isAttributeChangeTrackingPolicy());
ormAccessor.setValueHolderProperty(ormContainerMapping instanceof OneToOneMapping && ((OneToOneMapping)ormContainerMapping).usesIndirection());