// Path: src/main/java/com/_4dconcept/springframework/data/marklogic/MarklogicTypeUtils.java
// public class MarklogicTypeUtils {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(MarklogicTypeUtils.class);
// 
//     private static final Map<Class<?>,Class<?>> PRIMITIVE_MAP = new HashMap<>();
// 
//     static {
//         PRIMITIVE_MAP.put(boolean.class, Boolean.class);
//         PRIMITIVE_MAP.put(byte.class, Byte.class);
//         PRIMITIVE_MAP.put(char.class, Character.class);
//         PRIMITIVE_MAP.put(short.class, Short.class);
//         PRIMITIVE_MAP.put(int.class, Integer.class);
//         PRIMITIVE_MAP.put(long.class, Long.class);
//         PRIMITIVE_MAP.put(float.class, Float.class);
//         PRIMITIVE_MAP.put(double.class, Double.class);
//     }
// 
//     private MarklogicTypeUtils() {}
// 
//     public static boolean isSimpleType(Class<?> type) {
//         return type.isPrimitive() || type.equals(String.class) || isBoxingType(type);
//     }
// 
//     public static <T> T convertStringToPrimitive(Class<T> returnType, String value) {
//         try {
//             Method m = PRIMITIVE_MAP.get(returnType).getMethod("valueOf", String.class);
//             @SuppressWarnings("unchecked") // Trust the valueOf method of the boxing type
//             T result = (T) m.invoke(null, value);
//             return result;
//         } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
//             LOGGER.debug("Unable to generate primitive value for type {}", returnType.getName());
//             return null;
//         }
//     }
// 
//     /**
//      * Retrieve the first non XmlTransient annotated type from deeperType to upperType.
//      *
//      * @param deeperType the deeperType of the hierarchy to test
//      * @param upperType the upperType of the hierarchy to test
//      * @return the xml eligible type
//      */
//     public static Class<?> resolveXmlType(Class<?> deeperType, Class<?> upperType) {
//         if (!deeperType.isAssignableFrom(upperType)) {
//             throw new IllegalArgumentException(String.format("%s --> %s is not a valid hierarchy", upperType, deeperType));
//         }
// 
//         Deque<Class<?>> types = new ArrayDeque<>();
// 
//         Class<?> currentType = upperType;
//         while (! deeperType.equals(currentType)) {
//             types.push(currentType);
//             currentType = currentType.getSuperclass();
//         }
// 
//         types.push(deeperType);
// 
//         while (! types.isEmpty()) {
//             Class<?> type = types.pop();
//             if (type.getAnnotation(XmlTransient.class) == null) {
//                 return type;
//             }
//         }
// 
//         throw new IllegalArgumentException(String.format("Unable to determine a non XmlTransient type in provided hierarchy %s --> %s", upperType, deeperType));
//     }
// 
//     public static boolean isSupportedType(Class<?> aClass) {
//         return MarklogicSupportedType.fromClass(aClass).isPresent();
//     }
// 
//     private static boolean isBoxingType(Class<?> type) {
//         return MarklogicTypeUtils.PRIMITIVE_MAP.values().contains(type);
//     }
// }


import com._4dconcept.springframework.data.marklogic.MarklogicTypeUtils;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.lang.Nullable;
import javax.xml.bind.annotation.*;
import javax.xml.namespace.QName;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
        if (xmlElement != null) {
            if (!xmlElement.namespace().equals(XML_DEFAULT)) {
                namespaceUri = xmlElement.namespace();
            }

            localName = xmlElement.name().equals(XML_DEFAULT) ? getName() : xmlElement.name();
        }

        if (namespaceUri == null && this.getField() != null) {
            namespaceUri = resolvesNamespaceUriFromEnclosingType(this.getField().getDeclaringClass());
        }

        if (namespaceUri == null) namespaceUri = "";
        if (localName == null) localName = getName();

        return new QName(namespaceUri, localName);
    }

    @Override
    protected Association<MarklogicPersistentProperty> createAssociation() {
        return new Association<>(this, null);
    }

    @Override
    public Optional<Method> getReadMethod() {
        return getProperty().getGetter();
    }

    @Nullable
    private String resolvesNamespaceUriFromEnclosingType(Class<?> type) {
// Path: src/main/java/com/_4dconcept/springframework/data/marklogic/MarklogicTypeUtils.java
// public class MarklogicTypeUtils {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(MarklogicTypeUtils.class);
// 
//     private static final Map<Class<?>,Class<?>> PRIMITIVE_MAP = new HashMap<>();
// 
//     static {
//         PRIMITIVE_MAP.put(boolean.class, Boolean.class);
//         PRIMITIVE_MAP.put(byte.class, Byte.class);
//         PRIMITIVE_MAP.put(char.class, Character.class);
//         PRIMITIVE_MAP.put(short.class, Short.class);
//         PRIMITIVE_MAP.put(int.class, Integer.class);
//         PRIMITIVE_MAP.put(long.class, Long.class);
//         PRIMITIVE_MAP.put(float.class, Float.class);
//         PRIMITIVE_MAP.put(double.class, Double.class);
//     }
// 
//     private MarklogicTypeUtils() {}
// 
//     public static boolean isSimpleType(Class<?> type) {
//         return type.isPrimitive() || type.equals(String.class) || isBoxingType(type);
//     }
// 
//     public static <T> T convertStringToPrimitive(Class<T> returnType, String value) {
//         try {
//             Method m = PRIMITIVE_MAP.get(returnType).getMethod("valueOf", String.class);
//             @SuppressWarnings("unchecked") // Trust the valueOf method of the boxing type
//             T result = (T) m.invoke(null, value);
//             return result;
//         } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
//             LOGGER.debug("Unable to generate primitive value for type {}", returnType.getName());
//             return null;
//         }
//     }
// 
//     /**
//      * Retrieve the first non XmlTransient annotated type from deeperType to upperType.
//      *
//      * @param deeperType the deeperType of the hierarchy to test
//      * @param upperType the upperType of the hierarchy to test
//      * @return the xml eligible type
//      */
//     public static Class<?> resolveXmlType(Class<?> deeperType, Class<?> upperType) {
//         if (!deeperType.isAssignableFrom(upperType)) {
//             throw new IllegalArgumentException(String.format("%s --> %s is not a valid hierarchy", upperType, deeperType));
//         }
// 
//         Deque<Class<?>> types = new ArrayDeque<>();
// 
//         Class<?> currentType = upperType;
//         while (! deeperType.equals(currentType)) {
//             types.push(currentType);
//             currentType = currentType.getSuperclass();
//         }
// 
//         types.push(deeperType);
// 
//         while (! types.isEmpty()) {
//             Class<?> type = types.pop();
//             if (type.getAnnotation(XmlTransient.class) == null) {
//                 return type;
//             }
//         }
// 
//         throw new IllegalArgumentException(String.format("Unable to determine a non XmlTransient type in provided hierarchy %s --> %s", upperType, deeperType));
//     }
// 
//     public static boolean isSupportedType(Class<?> aClass) {
//         return MarklogicSupportedType.fromClass(aClass).isPresent();
//     }
// 
//     private static boolean isBoxingType(Class<?> type) {
//         return MarklogicTypeUtils.PRIMITIVE_MAP.values().contains(type);
//     }
// }


// Path: src/main/java/com/_4dconcept/springframework/data/marklogic/core/mapping/BasicMarklogicPersistentProperty.java
import com._4dconcept.springframework.data.marklogic.MarklogicTypeUtils;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.lang.Nullable;
import javax.xml.bind.annotation.*;
import javax.xml.namespace.QName;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

        if (xmlElement != null) {
            if (!xmlElement.namespace().equals(XML_DEFAULT)) {
                namespaceUri = xmlElement.namespace();
            }

            localName = xmlElement.name().equals(XML_DEFAULT) ? getName() : xmlElement.name();
        }

        if (namespaceUri == null && this.getField() != null) {
            namespaceUri = resolvesNamespaceUriFromEnclosingType(this.getField().getDeclaringClass());
        }

        if (namespaceUri == null) namespaceUri = "";
        if (localName == null) localName = getName();

        return new QName(namespaceUri, localName);
    }

    @Override
    protected Association<MarklogicPersistentProperty> createAssociation() {
        return new Association<>(this, null);
    }

    @Override
    public Optional<Method> getReadMethod() {
        return getProperty().getGetter();
    }

    @Nullable
    private String resolvesNamespaceUriFromEnclosingType(Class<?> type) {
        Class<?> xmlType = MarklogicTypeUtils.resolveXmlType(type, this.getOwner().getType());