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 Object clone() { // Bug 3037701 - clone the AttributeAccessor XMLAnyCollectionMapping mapping = null; mapping = (XMLAnyCollectionMapping) super.clone(); mapping.setContainerPolicy(this.getContainerPolicy()); mapping.setField(this.getField()); return mapping; }
public Object clone() { // Bug 3037701 - clone the AttributeAccessor XMLAnyCollectionMapping mapping = null; mapping = (XMLAnyCollectionMapping) super.clone(); mapping.setContainerPolicy(this.getContainerPolicy()); mapping.setField(this.getField()); return mapping; }
/** * INTERNAL: */ protected XMLDirectMapping getPreRemoveMapping() { XMLDirectMapping preRemoveMapping = new XMLDirectMapping(); preRemoveMapping.setAttributeName("m_preRemove"); preRemoveMapping.setGetMethodName("getPreRemove"); preRemoveMapping.setSetMethodName("setPreRemove"); preRemoveMapping.setXPath("orm:pre-remove/@method-name"); return preRemoveMapping; }
/** * INTERNAL: */ protected XMLCompositeObjectMapping getAttributesMapping() { XMLCompositeObjectMapping attributesMapping = new XMLCompositeObjectMapping(); attributesMapping.setAttributeName("m_attributes"); attributesMapping.setGetMethodName("getAttributes"); attributesMapping.setSetMethodName("setAttributes"); attributesMapping.setReferenceClass(XMLAttributes.class); attributesMapping.setXPath("orm:attributes"); return attributesMapping; }
/** * Return a new aggregate/embedded mapping for this type of descriptor. */ @Override public AggregateMapping newAggregateMapping() { return new XMLCompositeObjectMapping(); }
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; }
/** * Get the XPath String * @return String the XPath String associated with this Mapping */ public String getXPath() { return getFieldName(); }
/** * INTERNAL */ public String getMimeType() { if(mimeTypePolicy == null) { return null; } return mimeTypePolicy.getMimeType(null); }
@Override public Class getAttributeElementClass() { Class elementClass = super.getAttributeElementClass(); if(elementClass == null) { return this.collectionContentType; } return elementClass; }
/** * INTERNAL: */ protected XMLDirectMapping getQueryMapping() { XMLDirectMapping queryMapping = new XMLDirectMapping(); queryMapping.setAttributeName("m_query"); queryMapping.setGetMethodName("getQuery"); queryMapping.setSetMethodName("setQuery"); queryMapping.setXPath("orm:query"); return queryMapping; }
/** * INTERNAL: */ protected XMLCompositeObjectMapping getReturnInsertMapping() { XMLCompositeObjectMapping mapping = new XMLCompositeObjectMapping(); mapping.setAttributeName("m_returnInsert"); mapping.setGetMethodName("getReturnInsert"); mapping.setSetMethodName("setReturnInsert"); mapping.setReferenceClass(ReturnInsertMetadata.class); mapping.setXPath("orm:return-insert"); return mapping; }
public Object clone() { // Bug 3037701 - clone the AttributeAccessor XMLAnyCollectionMapping mapping = null; mapping = (XMLAnyCollectionMapping) super.clone(); mapping.setContainerPolicy(this.getContainerPolicy()); mapping.setField(this.getField()); return mapping; }
public Object clone() { // Bug 3037701 - clone the AttributeAccessor XMLAnyCollectionMapping mapping = null; mapping = (XMLAnyCollectionMapping) super.clone(); mapping.setContainerPolicy(this.getContainerPolicy()); mapping.setField(this.getField()); return mapping; }
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); } } } } }
/** * INTERNAL: */ protected XMLDirectMapping getQueryParameterAttributeMapping() { XMLDirectMapping queryParameterMapping = new XMLDirectMapping(); queryParameterMapping.setAttributeName("m_queryParameter"); queryParameterMapping.setGetMethodName("getQueryParameter"); queryParameterMapping.setSetMethodName("setQueryParameter"); queryParameterMapping.setXPath("@query-parameter"); return queryParameterMapping; }
public Object clone() { // Bug 3037701 - clone the AttributeAccessor XMLAnyCollectionMapping mapping = null; mapping = (XMLAnyCollectionMapping) super.clone(); mapping.setContainerPolicy(this.getContainerPolicy()); mapping.setField(this.getField()); return mapping; }
public Object clone() { // Bug 3037701 - clone the AttributeAccessor XMLAnyCollectionMapping mapping = null; mapping = (XMLAnyCollectionMapping) super.clone(); mapping.setContainerPolicy(this.getContainerPolicy()); mapping.setField(this.getField()); return mapping; }
/** * INTERNAL */ protected XMLDirectMapping getUniqueAttributeMapping() { XMLDirectMapping uniqueMapping = new XMLDirectMapping(); uniqueMapping.setAttributeName("m_unique"); uniqueMapping.setGetMethodName("getUnique"); uniqueMapping.setSetMethodName("setUnique"); uniqueMapping.setXPath("@unique"); return uniqueMapping; }
/** * INTERNAL: */ protected XMLDirectMapping getValueAttributeMapping() { XMLDirectMapping valueMapping = new XMLDirectMapping(); valueMapping.setAttributeName("m_value"); valueMapping.setGetMethodName("getValue"); valueMapping.setSetMethodName("setValue"); valueMapping.setXPath("@value"); return valueMapping; }