private Type getContainerType(final boolean isIndividual) { final XPathNodeWrapper currentNodeWrapper = getCurrentNodeWrapper(); if (currentNodeWrapper.nodeValue != null && currentNodeWrapper.nodeValue.isContainerValue()) { final DatabaseMapping mapping = currentNodeWrapper.nodeValue.getMapping(); Converter valueConverter = null; if (mapping != null) { if (isIndividual) { if (mapping instanceof AbstractCompositeDirectCollectionMapping) { valueConverter = ((AbstractCompositeDirectCollectionMapping) mapping).getValueConverter(); } else if (mapping instanceof XMLCompositeCollectionMapping) { valueConverter = ((XMLCompositeCollectionMapping) mapping).getConverter(); } } if (valueConverter instanceof TypeConversionConverter) { return ((TypeConversionConverter) valueConverter).getObjectClass(); } else if (mapping.getContainerPolicy() != null) { return mapping.getContainerPolicy().getContainerClass(); } } } return null; }
import org.eclipse.persistence.config.DescriptorCustomizer; import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; import org.eclipse.persistence.oxm.mappings.nullpolicy.XMLNullRepresentationType; public class AddressCustomizer implements DescriptorCustomizer { @Override public void customize(ClassDescriptor descriptor) throws Exception { for(DatabaseMapping mapping : descriptor.getMappings()) { if(mapping.isAbstractDirectMapping()) { XMLDirectMapping xmlDirectMapping = (XMLDirectMapping) mapping; xmlDirectMapping.getNullPolicy().setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE); xmlDirectMapping.getNullPolicy().setNullRepresentedByEmptyNode(true); } } } }
/** * PUBLIC: * Sets the name of the attribute in the mapping. */ @Override public void setAttributeName(String attributeName) { getAttributeAccessor().setAttributeName(attributeName); // Clear the mapping attribute name until a getAttributeName() call copies the accessor attributeName this.attributeName = null; }
ClassDescriptor descriptor = nodeValue.getMapping().getReferenceDescriptor(); descriptor = nodeValue.getMapping().getDescriptor();
/** * INTERNAL: * Return the DatabaseField that represents the key in a DirectMapMapping. If the * keyMapping is not a DirectMapping, this will return null * @return */ public DatabaseField getDirectKeyField(CollectionMapping baseMapping){ if (((DatabaseMapping)keyMapping).isDirectToFieldMapping()){ return ((DirectToFieldMapping)keyMapping).getField(); } return null; }
public void preInitialize(AbstractSession session){ super.preInitialize(session); if(inlineMapping != null){ inlineMapping.setDescriptor(this.descriptor); inlineMapping.preInitialize(session); } }
/** * PUBLIC: * Return the name of the attribute set in the mapping. */ public String getAttributeName() { // The attribute name on the attributeAccessor will always override any attribute already set // Use the attributeAccessor attribute over the current attribute name if (attributeName == null) { attributeName = getAttributeAccessor().getAttributeName(); } return attributeName; }
/** * PUBLIC: * Return if method access is used. */ public boolean isUsingMethodAccess() { return getAttributeAccessor().isMethodAttributeAccessor(); }
/** * INTERNAL: * Selection criteria is created to read target records from the table. */ protected void initializeSelectionCriteriaAndAddFieldsToQuery(Expression startCriteria) { setSelectionCriteria(this.mechanism.buildSelectionCriteriaAndAddFieldsToQuery(this, startCriteria)); }
/** * INTERNAL: * Adds locking clause to the target query to extend pessimistic lock scope. */ @Override protected void extendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) { if(this.mechanism == null) { super.extendPessimisticLockScopeInTargetQuery(targetQuery, sourceQuery); } else { this.mechanism.setRelationTableLockingClause(targetQuery, sourceQuery); } }
/** * INTERNAL: * Once descriptors are serialized to the remote session. All its mappings and reference descriptors are traversed. Usually * mappings are initialized and serialized reference descriptors are replaced with local descriptors if they already exist on the * remote session. */ @Override public void remoteInitialization(DistributedSession session) { super.remoteInitialization(session); setTempSession(session); }
/** * INTERNAL: * Compare the attributes belonging to this mapping for the objects. */ @Override public boolean compareObjects(Object firstObject, Object secondObject, AbstractSession session) { Object firstObjectCollection = getRealCollectionAttributeValueFromObject(firstObject, session); Object secondObjectCollection = getRealCollectionAttributeValueFromObject(secondObject, session); return super.compareObjects(firstObjectCollection, secondObjectCollection, session); }
/** * INTERNAL: * Should be overridden by subclass that allows setting * extendPessimisticLockScope to DEDICATED_QUERY. */ protected ReadQuery getExtendPessimisticLockScopeDedicatedQuery(AbstractSession session, short lockMode) { if(this.mechanism != null) { return this.mechanism.getLockRelationTableQueryClone(session, lockMode); } else { return super.getExtendPessimisticLockScopeDedicatedQuery(session, lockMode); } }
/** * PUBLIC: * Sets the name of the attribute in the mapping. */ @Override public void setAttributeName(String attributeName) { getAttributeAccessor().setAttributeName(attributeName); // Clear the mapping attribute name until a getAttributeName() call copies the accessor attributeName this.attributeName = null; }
public void preInitialize(AbstractSession session){ super.preInitialize(session); if(inlineMapping != null){ inlineMapping.setDescriptor(this.descriptor); inlineMapping.preInitialize(session); } }
/** * INTERNAL: * Selection criteria is created to read target records from the table. */ protected void initializeSelectionCriteriaAndAddFieldsToQuery(Expression startCriteria) { setSelectionCriteria(this.mechanism.buildSelectionCriteriaAndAddFieldsToQuery(this, startCriteria)); }
/** * INTERNAL: * Adds locking clause to the target query to extend pessimistic lock scope. */ protected void extendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) { if(this.mechanism == null) { super.extendPessimisticLockScopeInTargetQuery(targetQuery, sourceQuery); } else { this.mechanism.setRelationTableLockingClause(targetQuery, sourceQuery); } }
import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; import org.eclipse.persistence.oxm.mappings.nullpolicy.XMLNullRepresentationType; import org.eclipse.persistence.sessions.*; public class NullPolicySessionEventListener extends SessionEventAdapter { @Override public void preLogin(SessionEvent event) { Project project = event.getSession().getProject(); for(ClassDescriptor descriptor : project.getOrderedDescriptors()) { for(DatabaseMapping mapping : descriptor.getMappings()) { if(mapping.isAbstractDirectMapping()) { XMLDirectMapping xmlDirectMapping = (XMLDirectMapping) mapping; xmlDirectMapping.getNullPolicy().setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE); xmlDirectMapping.getNullPolicy().setNullRepresentedByEmptyNode(true); } } } } }
/** * PUBLIC: * Sets the name of the attribute in the mapping. */ public void setAttributeName(String attributeName) { getAttributeAccessor().setAttributeName(attributeName); // Clear the mapping attribute name until a getAttributeName() call copies the accessor attributeName this.attributeName = null; }