protected void addConverterMappings(ClassDescriptor descriptor) { descriptor.addMapping(getConverterMapping()); descriptor.addMapping(getTypeConverterMapping()); descriptor.addMapping(getObjectTypeConverterMapping()); descriptor.addMapping(getSerializedConverterMapping()); descriptor.addMapping(getStructConverterMapping()); }
import org.eclipse.persistence.config.DescriptorCustomizer; import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.mappings.xdb.DirectToXMLTypeMapping; public class XMLDataCustomizer implements DescriptorCustomizer { public void customize(final ClassDescriptor descriptor) throws Exception { descriptor.removeMappingForAttributeName("xmlField"); DirectToXMLTypeMapping mapping = new DirectToXMLTypeMapping(); mapping.setAttributeName("xmlField"); //name of the atribute on the Entity Bean mapping.setFieldName("XML_COLUMN"); //name of the data base column descriptor.addMapping(mapping); } }
/** * PUBLIC: * Add a direct to field mapping to the receiver. The new mapping specifies that * an instance variable of the class of objects which the receiver describes maps in * the default manner for its type to the indicated database field. * * @param attributeName is the name of an instance variable of the * class which the receiver describes. * @param fieldName is the name of the database column which corresponds * with the designated instance variable. * @return The newly created DatabaseMapping is returned. */ public DatabaseMapping addDirectMapping(String attributeName, String fieldName) { AbstractDirectMapping mapping = newDirectMapping(); mapping.setAttributeName(attributeName); mapping.setField(new DatabaseField(fieldName)); return addMapping(mapping); }
protected ClassDescriptor buildXMLChoiceFieldToClassAssociationDescriptor() { ClassDescriptor descriptor = super.buildXMLChoiceFieldToClassAssociationDescriptor(); XMLCompositeObjectMapping converterMapping = new XMLCompositeObjectMapping(); converterMapping.setAttributeName("converter"); converterMapping.setXPath(getPrimaryNamespacePrefix() + "value-converter"); converterMapping.setReferenceClass(Converter.class); descriptor.addMapping(converterMapping); return descriptor; }
protected ClassDescriptor buildXMLChoiceFieldToClassAssociationDescriptor() { ClassDescriptor descriptor = super.buildXMLChoiceFieldToClassAssociationDescriptor(); XMLCompositeObjectMapping converterMapping = new XMLCompositeObjectMapping(); converterMapping.setAttributeName("converter"); converterMapping.setXPath(getPrimaryNamespacePrefix() + "value-converter"); converterMapping.setReferenceClass(Converter.class); descriptor.addMapping(converterMapping); return descriptor; }
/** * PUBLIC: * Add a direct to field mapping to the receiver. The new mapping specifies that * a variable accessed by the get and set methods of the class of objects which * the receiver describes maps in the default manner for its type to the indicated * database field. */ public DatabaseMapping addDirectMapping(String attributeName, String getMethodName, String setMethodName, String fieldName) { DirectToFieldMapping mapping = new DirectToFieldMapping(); mapping.setAttributeName(attributeName); mapping.setSetMethodName(setMethodName); mapping.setGetMethodName(getMethodName); mapping.setFieldName(fieldName); return addMapping(mapping); }
protected ClassDescriptor buildXMLChoiceFieldToClassAssociationDescriptor() { ClassDescriptor descriptor = super.buildXMLChoiceFieldToClassAssociationDescriptor(); XMLCompositeObjectMapping converterMapping = new XMLCompositeObjectMapping(); converterMapping.setAttributeName("converter"); converterMapping.setXPath(getPrimaryNamespacePrefix() + "value-converter"); converterMapping.setReferenceClass(Converter.class); descriptor.addMapping(converterMapping); return descriptor; }
import org.eclipse.persistence.config.DescriptorCustomizer; import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping; public class PhoneNumberCustomizer implements DescriptorCustomizer { @Override public void customize(ClassDescriptor descriptor) throws Exception { descriptor.removeMappingForAttributeName("contact"); XMLObjectReferenceMapping contactMapping = new XMLObjectReferenceMapping(); contactMapping.setAttributeName("contact"); contactMapping.setReferenceClass(Employee.class); contactMapping.addSourceToTargetKeyFieldAssociation("contact/@eID", "eId/text()"); contactMapping.addSourceToTargetKeyFieldAssociation("contact/@country", "country/text()"); descriptor.addMapping(contactMapping); } }
protected ClassDescriptor buildOXXMLDescriptorDescriptor() { ClassDescriptor descriptor = super.buildOXXMLDescriptorDescriptor(); XMLDirectMapping alwaysXMLRootMapping = new XMLDirectMapping(); alwaysXMLRootMapping.setAttributeName("resultAlwaysXMLRoot"); alwaysXMLRootMapping.setGetMethodName("isResultAlwaysXMLRoot"); alwaysXMLRootMapping.setSetMethodName("setResultAlwaysXMLRoot"); alwaysXMLRootMapping.setNullValue(Boolean.FALSE); alwaysXMLRootMapping.setXPath(getPrimaryNamespaceXPath() + "result-always-xml-root/text()"); descriptor.addMapping(alwaysXMLRootMapping); return descriptor; }
protected ClassDescriptor buildOXXMLDescriptorDescriptor() { ClassDescriptor descriptor = super.buildOXXMLDescriptorDescriptor(); XMLDirectMapping alwaysXMLRootMapping = new XMLDirectMapping(); alwaysXMLRootMapping.setAttributeName("resultAlwaysXMLRoot"); alwaysXMLRootMapping.setGetMethodName("isResultAlwaysXMLRoot"); alwaysXMLRootMapping.setSetMethodName("setResultAlwaysXMLRoot"); alwaysXMLRootMapping.setNullValue(Boolean.FALSE); alwaysXMLRootMapping.setXPath(getPrimaryNamespaceXPath() + "result-always-xml-root/text()"); descriptor.addMapping(alwaysXMLRootMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLCompositeObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLCompositeObjectMappingDescriptor(); // Add Null Policy XMLCompositeObjectMapping nullPolicyClassMapping = new XMLCompositeObjectMapping(); nullPolicyClassMapping.setReferenceClass(AbstractNullPolicy.class); nullPolicyClassMapping.setAttributeName("nullPolicy"); nullPolicyClassMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); // Handle translation of (default) Null Policy states. ((DatabaseMapping)nullPolicyClassMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(nullPolicyClassMapping); return descriptor; }
protected ClassDescriptor buildOXXMLDescriptorDescriptor() { ClassDescriptor descriptor = super.buildOXXMLDescriptorDescriptor(); XMLDirectMapping alwaysXMLRootMapping = new XMLDirectMapping(); alwaysXMLRootMapping.setAttributeName("resultAlwaysXMLRoot"); alwaysXMLRootMapping.setGetMethodName("isResultAlwaysXMLRoot"); alwaysXMLRootMapping.setSetMethodName("setResultAlwaysXMLRoot"); alwaysXMLRootMapping.setNullValue(Boolean.FALSE); alwaysXMLRootMapping.setXPath(getPrimaryNamespaceXPath() + "result-always-xml-root/text()"); descriptor.addMapping(alwaysXMLRootMapping); return descriptor; }
protected ClassDescriptor buildXMLAnyObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLAnyObjectMappingDescriptor(); XMLDirectMapping keepAsElementMapping = new XMLDirectMapping(); keepAsElementMapping.setAttributeName("keepAsElementPolicy"); keepAsElementMapping.setGetMethodName("getKeepAsElementPolicy"); keepAsElementMapping.setSetMethodName("setKeepAsElementPolicy"); keepAsElementMapping.setXPath(getPrimaryNamespaceXPath() + "keep-as-element-policy"); EnumTypeConverter converter = new EnumTypeConverter(keepAsElementMapping, UnmarshalKeepAsElementPolicy.class, false); keepAsElementMapping.setConverter(converter); descriptor.addMapping(keepAsElementMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLCompositeObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLCompositeObjectMappingDescriptor(); // Add Null Policy XMLCompositeObjectMapping nullPolicyClassMapping = new XMLCompositeObjectMapping(); nullPolicyClassMapping.setReferenceClass(AbstractNullPolicy.class); nullPolicyClassMapping.setAttributeName("nullPolicy"); nullPolicyClassMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); // Handle translation of (default) Null Policy states. ((DatabaseMapping)nullPolicyClassMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(nullPolicyClassMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLCompositeObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLCompositeObjectMappingDescriptor(); // Add Null Policy XMLCompositeObjectMapping nullPolicyClassMapping = new XMLCompositeObjectMapping(); nullPolicyClassMapping.setReferenceClass(AbstractNullPolicy.class); nullPolicyClassMapping.setAttributeName("nullPolicy"); nullPolicyClassMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); // Handle translation of (default) Null Policy states. ((DatabaseMapping)nullPolicyClassMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(nullPolicyClassMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLDirectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLDirectMappingDescriptor(); XMLDirectMapping isCDATAMapping = new XMLDirectMapping(); isCDATAMapping.setAttributeName("isCDATA"); isCDATAMapping.setGetMethodName("isCDATA"); isCDATAMapping.setSetMethodName("setIsCDATA"); isCDATAMapping.setXPath(getPrimaryNamespaceXPath() + "is-cdata/text()"); isCDATAMapping.setNullValue(Boolean.FALSE); descriptor.addMapping(isCDATAMapping); // Add Null Policy XMLCompositeObjectMapping aMapping = new XMLCompositeObjectMapping(); aMapping.setReferenceClass(AbstractNullPolicy.class); aMapping.setAttributeName("nullPolicy"); aMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); ((DatabaseMapping)aMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(aMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLLoginDescriptor(){ ClassDescriptor descriptor = super.buildXMLLoginDescriptor(); XMLDirectMapping equalNamespaceResolversMapping = new XMLDirectMapping(); equalNamespaceResolversMapping.setAttributeName("equalNamespaceResolvers"); equalNamespaceResolversMapping.setGetMethodName("hasEqualNamespaceResolvers"); equalNamespaceResolversMapping.setSetMethodName("setEqualNamespaceResolvers"); equalNamespaceResolversMapping.setXPath(getPrimaryNamespaceXPath() + "equal-namespace-resolvers/text()"); equalNamespaceResolversMapping.setNullValue(Boolean.TRUE); descriptor.addMapping(equalNamespaceResolversMapping); XMLCompositeObjectMapping documentPreservationPolicyMapping = new XMLCompositeObjectMapping(); documentPreservationPolicyMapping.setReferenceClass(DocumentPreservationPolicy.class); documentPreservationPolicyMapping.setAttributeName("documentPreservationPolicy"); documentPreservationPolicyMapping.setGetMethodName("getDocumentPreservationPolicy"); documentPreservationPolicyMapping.setSetMethodName("setDocumentPreservationPolicy"); documentPreservationPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "document-preservation-policy"); descriptor.addMapping(documentPreservationPolicyMapping); return descriptor; }
protected ClassDescriptor buildXMLAnyObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLAnyObjectMappingDescriptor(); XMLDirectMapping keepAsElementMapping = new XMLDirectMapping(); keepAsElementMapping.setAttributeName("keepAsElementPolicy"); keepAsElementMapping.setGetMethodName("getKeepAsElementPolicy"); keepAsElementMapping.setSetMethodName("setKeepAsElementPolicy"); keepAsElementMapping.setXPath(getPrimaryNamespaceXPath() + "keep-as-element-policy"); EnumTypeConverter converter = new EnumTypeConverter(keepAsElementMapping, UnmarshalKeepAsElementPolicy.class, false); keepAsElementMapping.setConverter(converter); descriptor.addMapping(keepAsElementMapping); return descriptor; }
protected ClassDescriptor buildXMLAnyObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLAnyObjectMappingDescriptor(); XMLDirectMapping keepAsElementMapping = new XMLDirectMapping(); keepAsElementMapping.setAttributeName("keepAsElementPolicy"); keepAsElementMapping.setGetMethodName("getKeepAsElementPolicy"); keepAsElementMapping.setSetMethodName("setKeepAsElementPolicy"); keepAsElementMapping.setXPath(getPrimaryNamespaceXPath() + "keep-as-element-policy"); EnumTypeConverter converter = new EnumTypeConverter(keepAsElementMapping, UnmarshalKeepAsElementPolicy.class, false); keepAsElementMapping.setConverter(converter); descriptor.addMapping(keepAsElementMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLDirectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLDirectMappingDescriptor(); XMLDirectMapping isCDATAMapping = new XMLDirectMapping(); isCDATAMapping.setAttributeName("isCDATA"); isCDATAMapping.setGetMethodName("isCDATA"); isCDATAMapping.setSetMethodName("setIsCDATA"); isCDATAMapping.setXPath(getPrimaryNamespaceXPath() + "is-cdata/text()"); isCDATAMapping.setNullValue(Boolean.FALSE); descriptor.addMapping(isCDATAMapping); // Add Null Policy XMLCompositeObjectMapping aMapping = new XMLCompositeObjectMapping(); aMapping.setReferenceClass(AbstractNullPolicy.class); aMapping.setAttributeName("nullPolicy"); aMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); ((DatabaseMapping)aMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(aMapping); return descriptor; }