Search in sources :

Example 1 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class MappingsGenerator method generateWrapperClassAndDescriptor.

private Class<?> generateWrapperClassAndDescriptor(TypeInfo type, QName next, ElementDeclaration nextElement, String nextClassName, String attributeTypeName) {
    String namespaceUri = null;
    if (next != null) {
        // generate a class/descriptor for this element
        namespaceUri = next.getNamespaceURI();
        if (namespaceUri == null || namespaceUri.equals(XMLProcessor.DEFAULT)) {
            namespaceUri = "";
        }
    }
    TypeMappingInfo tmi = nextElement.getTypeMappingInfo();
    Class<?> generatedClass = null;
    JaxbClassLoader loader = getJaxbClassLoader();
    if (tmi != null) {
        generatedClass = CompilerHelper.getExisitingGeneratedClass(tmi, typeMappingInfoToGeneratedClasses, typeMappingInfoToAdapterClasses, helper.getClassLoader());
        if (generatedClass == null) {
            generatedClass = this.generateWrapperClass(loader.nextAvailableGeneratedClassName(), attributeTypeName, nextElement.isList(), next);
        }
        typeMappingInfoToGeneratedClasses.put(tmi, generatedClass);
    } else {
        generatedClass = this.generateWrapperClass(loader.nextAvailableGeneratedClassName(), attributeTypeName, nextElement.isList(), next);
    }
    this.qNamesToGeneratedClasses.put(next, generatedClass);
    try {
        Class<Object> declaredClass = PrivilegedAccessHelper.getClassForName(nextClassName, false, helper.getClassLoader());
        this.qNamesToDeclaredClasses.put(next, declaredClass);
    } catch (Exception e) {
    }
    Descriptor desc = (Descriptor) project.getDescriptor(generatedClass);
    if (desc == null) {
        desc = new XMLDescriptor();
        desc.setJavaClass(generatedClass);
        if (nextElement.isList()) {
            DirectCollectionMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, Session, XMLUnmarshaller, XMLRecord> mapping = new XMLCompositeDirectCollectionMapping();
            mapping.setAttributeName("value");
            mapping.setXPath("text()");
            mapping.setUsesSingleNode(true);
            mapping.setReuseContainer(true);
            if (type != null && type.isEnumerationType()) {
                mapping.setValueConverter(buildJAXBEnumTypeConverter(mapping, (EnumTypeInfo) type));
            } else {
                try {
                    Class<Object> fieldElementClass = PrivilegedAccessHelper.getClassForName(nextClassName, false, helper.getClassLoader());
                    mapping.setFieldElementClass(fieldElementClass);
                } catch (ClassNotFoundException e) {
                }
            }
            if (nextClassName.equals("[B") || nextClassName.equals("[Ljava.lang.Byte;")) {
                ((Field) mapping.getField()).setSchemaType(Constants.BASE_64_BINARY_QNAME);
            } else if (nextClassName.equals("javax.xml.namespace.QName")) {
                ((Field) mapping.getField()).setSchemaType(Constants.QNAME_QNAME);
            }
            desc.addMapping((CoreMapping) mapping);
        } else {
            if (nextElement.getJavaTypeName().equals(OBJECT_CLASS_NAME)) {
                CompositeObjectMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, Session, UnmarshalKeepAsElementPolicy, XMLUnmarshaller, XMLRecord> mapping = new XMLCompositeObjectMapping();
                mapping.setAttributeName("value");
                mapping.setSetMethodName("setValue");
                mapping.setGetMethodName("getValue");
                mapping.setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
                mapping.setXPath(".");
                setTypedTextField((Field) mapping.getField());
                desc.addMapping((CoreMapping) mapping);
            } else if (isBinaryData(nextElement.getJavaType())) {
                BinaryDataMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, MimeTypePolicy, Session, XMLUnmarshaller, XMLRecord> mapping = new XMLBinaryDataMapping();
                mapping.setAttributeName("value");
                mapping.setXPath(".");
                ((Field) mapping.getField()).setSchemaType(Constants.BASE_64_BINARY_QNAME);
                mapping.setSetMethodName("setValue");
                mapping.setGetMethodName("getValue");
                mapping.getNullPolicy().setNullRepresentedByXsiNil(true);
                mapping.getNullPolicy().setNullRepresentedByEmptyNode(false);
                Class<?> attributeClassification = org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(attributeTypeName, helper.getClassLoader());
                mapping.setAttributeClassification(attributeClassification);
                mapping.setShouldInlineBinaryData(false);
                // if(nextElement.getTypeMappingInfo() != null) {
                mapping.setSwaRef(nextElement.isXmlAttachmentRef());
                mapping.setMimeType(nextElement.getXmlMimeType());
                // }
                desc.addMapping((CoreMapping) mapping);
            } else {
                DirectMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, Session, XMLUnmarshaller, XMLRecord> mapping = new XMLDirectMapping();
                mapping.setNullValueMarshalled(true);
                mapping.setAttributeName("value");
                mapping.setXPath("text()");
                mapping.setSetMethodName("setValue");
                mapping.setGetMethodName("getValue");
                if (nextElement.getDefaultValue() != null) {
                    mapping.setNullValue(nextElement.getDefaultValue());
                    mapping.getNullPolicy().setNullRepresentedByXsiNil(true);
                }
                if (helper.isBuiltInJavaType(nextElement.getJavaType())) {
                    Class<?> attributeClassification = null;
                    if (nextElement.getJavaType().isPrimitive()) {
                        attributeClassification = XMLConversionManager.getDefaultManager().convertClassNameToClass(attributeTypeName);
                    } else {
                        attributeClassification = org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(attributeTypeName, helper.getClassLoader());
                    }
                    mapping.setAttributeClassification(attributeClassification);
                }
                IsSetNullPolicy nullPolicy = new IsSetNullPolicy("isSetValue", false, true, XMLNullRepresentationType.ABSENT_NODE);
                // nullPolicy.setNullRepresentedByEmptyNode(true);
                mapping.setNullPolicy(nullPolicy);
                if (type != null && type.isEnumerationType()) {
                    mapping.setConverter(buildJAXBEnumTypeConverter(mapping, (EnumTypeInfo) type));
                }
                if (nextClassName.equals("[B") || nextClassName.equals("[Ljava.lang.Byte;")) {
                    ((Field) mapping.getField()).setSchemaType(Constants.BASE_64_BINARY_QNAME);
                } else if (nextClassName.equals("javax.xml.namespace.QName")) {
                    ((Field) mapping.getField()).setSchemaType(Constants.QNAME_QNAME);
                }
                if (nextElement.getJavaTypeAdapterClass() != null) {
                    mapping.setConverter(new XMLJavaTypeConverter(nextElement.getJavaTypeAdapterClass()));
                }
                desc.addMapping((CoreMapping) mapping);
            }
        }
        if (next != null) {
            NamespaceInfo info = getNamespaceInfoForURI(namespaceUri);
            if (info != null) {
                NamespaceResolver resolver = getNamespaceResolverForDescriptor(info);
                String prefix = null;
                if (namespaceUri != Constants.EMPTY_STRING) {
                    prefix = resolver.resolveNamespaceURI(namespaceUri);
                    if (prefix == null) {
                        prefix = getPrefixForNamespace(namespaceUri, resolver);
                    }
                }
                desc.setNamespaceResolver(resolver);
                if (nextElement.isXmlRootElement()) {
                    desc.setDefaultRootElement(getQualifiedString(prefix, next.getLocalPart()));
                } else {
                    desc.setDefaultRootElement("");
                    desc.addRootElement(getQualifiedString(prefix, next.getLocalPart()));
                    desc.setResultAlwaysXMLRoot(true);
                }
            } else {
                if (namespaceUri.equals("")) {
                    desc.setDefaultRootElement(next.getLocalPart());
                } else {
                    NamespaceResolver resolver = new org.eclipse.persistence.oxm.NamespaceResolver();
                    String prefix = getPrefixForNamespace(namespaceUri, resolver);
                    desc.setNamespaceResolver(resolver);
                    if (nextElement.isXmlRootElement()) {
                        desc.setDefaultRootElement(getQualifiedString(prefix, next.getLocalPart()));
                    } else {
                        desc.setDefaultRootElement("");
                        desc.addRootElement(getQualifiedString(prefix, next.getLocalPart()));
                        desc.setResultAlwaysXMLRoot(true);
                    }
                }
            }
        }
        project.addDescriptor((CoreDescriptor) desc);
    }
    return generatedClass;
}
Also used : ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) XMLMarshaller(org.eclipse.persistence.oxm.XMLMarshaller) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy) XmlIsSetNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy) XMLField(org.eclipse.persistence.oxm.XMLField) DatabaseField(org.eclipse.persistence.internal.helper.DatabaseField) Field(org.eclipse.persistence.internal.oxm.mappings.Field) JavaField(org.eclipse.persistence.jaxb.javamodel.JavaField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) CoreConverter(org.eclipse.persistence.core.mappings.converters.CoreConverter) JAXBEnumTypeConverter(org.eclipse.persistence.jaxb.JAXBEnumTypeConverter) JAXBElementConverter(org.eclipse.persistence.internal.jaxb.JAXBElementConverter) XMLListConverter(org.eclipse.persistence.oxm.mappings.converters.XMLListConverter) XMLConverter(org.eclipse.persistence.oxm.mappings.converters.XMLConverter) Converter(org.eclipse.persistence.mappings.converters.Converter) DefaultElementConverter(org.eclipse.persistence.internal.jaxb.DefaultElementConverter) DomHandlerConverter(org.eclipse.persistence.internal.jaxb.DomHandlerConverter) JAXBElementRootConverter(org.eclipse.persistence.internal.jaxb.JAXBElementRootConverter) XMLJavaTypeConverter(org.eclipse.persistence.internal.jaxb.XMLJavaTypeConverter) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) DirectMapping(org.eclipse.persistence.internal.oxm.mappings.DirectMapping) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) UnmarshalKeepAsElementPolicy(org.eclipse.persistence.oxm.mappings.UnmarshalKeepAsElementPolicy) TypeMappingInfo(org.eclipse.persistence.jaxb.TypeMappingInfo) JaxbClassLoader(org.eclipse.persistence.internal.jaxb.JaxbClassLoader) AbstractSession(org.eclipse.persistence.internal.sessions.AbstractSession) XMLJavaTypeConverter(org.eclipse.persistence.internal.jaxb.XMLJavaTypeConverter) CoreMapping(org.eclipse.persistence.core.mappings.CoreMapping) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping) XMLRecord(org.eclipse.persistence.oxm.record.XMLRecord) JAXBException(org.eclipse.persistence.exceptions.JAXBException) DescriptorException(org.eclipse.persistence.exceptions.DescriptorException) XMLBinaryDataMapping(org.eclipse.persistence.oxm.mappings.XMLBinaryDataMapping) BinaryDataMapping(org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping) XMLBinaryDataMapping(org.eclipse.persistence.oxm.mappings.XMLBinaryDataMapping) ContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) DatabaseField(org.eclipse.persistence.internal.helper.DatabaseField) ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) Descriptor(org.eclipse.persistence.internal.oxm.mappings.Descriptor) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) CoreDescriptor(org.eclipse.persistence.core.descriptors.CoreDescriptor) NamespaceResolver(org.eclipse.persistence.internal.oxm.NamespaceResolver) JavaClass(org.eclipse.persistence.jaxb.javamodel.JavaClass) VirtualAttributeAccessor(org.eclipse.persistence.internal.descriptors.VirtualAttributeAccessor) CustomAccessorAttributeAccessor(org.eclipse.persistence.internal.jaxb.CustomAccessorAttributeAccessor) JAXBSetMethodAttributeAccessor(org.eclipse.persistence.internal.jaxb.JAXBSetMethodAttributeAccessor) AttributeAccessor(org.eclipse.persistence.mappings.AttributeAccessor) JAXBArrayAttributeAccessor(org.eclipse.persistence.internal.jaxb.many.JAXBArrayAttributeAccessor) MapValueAttributeAccessor(org.eclipse.persistence.internal.jaxb.many.MapValueAttributeAccessor) MethodAttributeAccessor(org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor) InstanceVariableAttributeAccessor(org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping) Session(org.eclipse.persistence.sessions.Session) AbstractSession(org.eclipse.persistence.internal.sessions.AbstractSession)

Example 2 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class MappingsGenerator method getNullPolicyFromProperty.

/**
 * Convenience method which returns an AbstractNullPolicy built from an XmlAbstractNullPolicy.
 *
 * @param nsr if 'NullRepresentedByXsiNil' is true, this is the resolver
 *            that we will add the schema instance prefix/uri pair to
 * @see org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy
 * @see org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy
 */
private AbstractNullPolicy getNullPolicyFromProperty(Property property, NamespaceResolver nsr) {
    AbstractNullPolicy absNullPolicy = null;
    XmlAbstractNullPolicy xmlAbsNullPolicy = property.getNullPolicy();
    // policy is assumed to be one of XmlNullPolicy or XmlIsSetNullPolicy
    if (xmlAbsNullPolicy instanceof XmlNullPolicy) {
        XmlNullPolicy xmlNullPolicy = (XmlNullPolicy) xmlAbsNullPolicy;
        NullPolicy nullPolicy = new NullPolicy();
        nullPolicy.setSetPerformedForAbsentNode(xmlNullPolicy.isIsSetPerformedForAbsentNode());
        absNullPolicy = nullPolicy;
    } else {
        XmlIsSetNullPolicy xmlIsSetNullPolicy = (XmlIsSetNullPolicy) xmlAbsNullPolicy;
        IsSetNullPolicy isSetNullPolicy = new IsSetNullPolicy();
        isSetNullPolicy.setIsSetMethodName(xmlIsSetNullPolicy.getIsSetMethodName());
        // handle isSetParams
        ArrayList<Object> parameters = new ArrayList<>();
        ArrayList<Class<?>> parameterTypes = new ArrayList<>();
        List<XmlIsSetNullPolicy.IsSetParameter> params = xmlIsSetNullPolicy.getIsSetParameter();
        for (XmlIsSetNullPolicy.IsSetParameter param : params) {
            String valueStr = param.getValue();
            String typeStr = param.getType();
            // create a conversion manager instance with the helper's loader
            XMLConversionManager mgr = new XMLConversionManager();
            mgr.setLoader(helper.getClassLoader());
            // handle parameter type
            Class<Object> typeClass = mgr.convertClassNameToClass(typeStr);
            // handle parameter value
            Object parameterValue = mgr.convertObject(valueStr, typeClass);
            parameters.add(parameterValue);
            parameterTypes.add(typeClass);
        }
        isSetNullPolicy.setIsSetParameters(parameters.toArray());
        isSetNullPolicy.setIsSetParameterTypes(parameterTypes.toArray(new Class<?>[parameterTypes.size()]));
        absNullPolicy = isSetNullPolicy;
    }
    // handle commmon settings
    absNullPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.valueOf(xmlAbsNullPolicy.getNullRepresentationForXml().name()));
    absNullPolicy.setNullRepresentedByEmptyNode(xmlAbsNullPolicy.isEmptyNodeRepresentsNull());
    boolean xsiRepresentsNull = xmlAbsNullPolicy.isXsiNilRepresentsNull();
    if (xsiRepresentsNull) {
        absNullPolicy.setNullRepresentedByXsiNil(true);
    }
    return absNullPolicy;
}
Also used : XmlAbstractNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy) AbstractNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy) XmlIsSetNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy) NullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.NullPolicy) XmlNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlNullPolicy) XmlAbstractNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy) AbstractNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy) ArrayList(java.util.ArrayList) XmlAbstractNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy) XmlIsSetNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy) XmlNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlNullPolicy) JavaClass(org.eclipse.persistence.jaxb.javamodel.JavaClass) XmlIsSetNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy) XMLConversionManager(org.eclipse.persistence.internal.oxm.XMLConversionManager)

Example 3 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class XMLEntityMappingsMappingProject method buildCascadeTypeDescriptor.

/**
 * INTERNAL:
 * XSD: cascade-type
 */
protected ClassDescriptor buildCascadeTypeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(CascadeMetadata.class);
    XMLDirectMapping cascadeAllMapping = new XMLDirectMapping();
    cascadeAllMapping.setAttributeName("m_cascadeAll");
    cascadeAllMapping.setGetMethodName("getCascadeAll");
    cascadeAllMapping.setSetMethodName("setCascadeAll");
    cascadeAllMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy cascadeAllPolicy = new IsSetNullPolicy("isCascadeAll");
    cascadeAllPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    cascadeAllMapping.setNullPolicy(cascadeAllPolicy);
    cascadeAllMapping.setXPath("orm:cascade-all");
    descriptor.addMapping(cascadeAllMapping);
    descriptor.addMapping(getCascadePersistMapping());
    XMLDirectMapping cascadeMergeMapping = new XMLDirectMapping();
    cascadeMergeMapping.setAttributeName("m_cascadeMerge");
    cascadeMergeMapping.setGetMethodName("getCascadeMerge");
    cascadeMergeMapping.setSetMethodName("setCascadeMerge");
    cascadeMergeMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy cascadeMergePolicy = new IsSetNullPolicy("isCascadeMerge");
    cascadeMergePolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    cascadeMergeMapping.setNullPolicy(cascadeMergePolicy);
    cascadeMergeMapping.setXPath("orm:cascade-merge");
    descriptor.addMapping(cascadeMergeMapping);
    XMLDirectMapping cascadeRemoveMapping = new XMLDirectMapping();
    cascadeRemoveMapping.setAttributeName("m_cascadeRemove");
    cascadeRemoveMapping.setGetMethodName("getCascadeRemove");
    cascadeRemoveMapping.setSetMethodName("setCascadeRemove");
    cascadeRemoveMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy cascadeRemovePolicy = new IsSetNullPolicy("isCascadeRemove");
    cascadeRemovePolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    cascadeRemoveMapping.setNullPolicy(cascadeRemovePolicy);
    cascadeRemoveMapping.setXPath("orm:cascade-remove");
    descriptor.addMapping(cascadeRemoveMapping);
    XMLDirectMapping cascadeRefreshMapping = new XMLDirectMapping();
    cascadeRefreshMapping.setAttributeName("m_cascadeRefresh");
    cascadeRefreshMapping.setGetMethodName("getCascadeRefresh");
    cascadeRefreshMapping.setSetMethodName("setCascadeRefresh");
    cascadeRefreshMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy cascadeRefreshPolicy = new IsSetNullPolicy("isCascadeRefresh");
    cascadeRefreshPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    cascadeRefreshMapping.setNullPolicy(cascadeRefreshPolicy);
    cascadeRefreshMapping.setXPath("orm:cascade-refresh");
    descriptor.addMapping(cascadeRefreshMapping);
    XMLDirectMapping cascadeDetachMapping = new XMLDirectMapping();
    cascadeDetachMapping.setAttributeName("m_cascadeDetach");
    cascadeDetachMapping.setGetMethodName("getCascadeDetach");
    cascadeDetachMapping.setSetMethodName("setCascadeDetach");
    cascadeDetachMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy cascadeDetachPolicy = new IsSetNullPolicy("isCascadeDetach");
    cascadeDetachPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    cascadeDetachMapping.setNullPolicy(cascadeDetachPolicy);
    cascadeDetachMapping.setXPath("orm:cascade-detach");
    descriptor.addMapping(cascadeDetachMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)

Example 4 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class XMLEntityMappingsMappingProject method getDeleteAllMapping.

/**
 * INTERNAL:
 */
protected XMLDirectMapping getDeleteAllMapping() {
    XMLDirectMapping deleteAllMapping = new XMLDirectMapping();
    deleteAllMapping.setAttributeName("m_deleteAll");
    deleteAllMapping.setGetMethodName("getDeleteAll");
    deleteAllMapping.setSetMethodName("setDeleteAll");
    deleteAllMapping.setXPath("orm:delete-all");
    deleteAllMapping.setConverter(new EmptyElementConverter());
    IsSetNullPolicy deleteAllPolicy = new IsSetNullPolicy("isDeleteAll");
    deleteAllPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    deleteAllMapping.setNullPolicy(deleteAllPolicy);
    return deleteAllMapping;
}
Also used : XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)

Example 5 with IsSetNullPolicy

use of org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy in project eclipselink by eclipse-ee4j.

the class XMLEntityMappingsMappingProject method getNonCacheableMapping.

/**
 * INTERNAL:
 */
protected XMLDirectMapping getNonCacheableMapping() {
    XMLDirectMapping noncacheable = new XMLDirectMapping();
    noncacheable.setAttributeName("m_nonCacheable");
    noncacheable.setGetMethodName("getNonCacheable");
    noncacheable.setSetMethodName("setNonCacheable");
    noncacheable.setConverter(new EmptyElementConverter());
    IsSetNullPolicy cacheablePolicy = new IsSetNullPolicy("isNonCacheable");
    cacheablePolicy.setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE);
    noncacheable.setNullPolicy(cacheablePolicy);
    noncacheable.setXPath("orm:noncacheable");
    return noncacheable;
}
Also used : XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)

Aggregations

IsSetNullPolicy (org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)14 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)11 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)4 XmlIsSetNullPolicy (org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy)3 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)2 AbstractNullPolicy (org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy)2 ArrayList (java.util.ArrayList)1 CoreDescriptor (org.eclipse.persistence.core.descriptors.CoreDescriptor)1 CoreMapping (org.eclipse.persistence.core.mappings.CoreMapping)1 CoreConverter (org.eclipse.persistence.core.mappings.converters.CoreConverter)1 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)1 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)1 JAXBException (org.eclipse.persistence.exceptions.JAXBException)1 InstanceVariableAttributeAccessor (org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor)1 MethodAttributeAccessor (org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor)1 VirtualAttributeAccessor (org.eclipse.persistence.internal.descriptors.VirtualAttributeAccessor)1 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)1 CustomAccessorAttributeAccessor (org.eclipse.persistence.internal.jaxb.CustomAccessorAttributeAccessor)1 DefaultElementConverter (org.eclipse.persistence.internal.jaxb.DefaultElementConverter)1 DomHandlerConverter (org.eclipse.persistence.internal.jaxb.DomHandlerConverter)1