Package org.jpox.store.mapped.mapping

Source Code of org.jpox.store.mapped.mapping.AbstractMappingManager$TypeMapping

/******************************************************************
Copyright (c) 2004 Andy Jefferson and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributors:
    ...
*****************************************************************/
package org.jpox.store.mapped.mapping;

import org.jpox.ClassLoaderResolver;
import org.jpox.ClassNameConstants;
import org.jpox.ObjectManagerFactoryImpl;
import org.jpox.TypeManager;
import org.jpox.api.ApiAdapter;
import org.jpox.exceptions.JPOXException;
import org.jpox.exceptions.JPOXUserException;
import org.jpox.metadata.AbstractClassMetaData;
import org.jpox.metadata.AbstractMemberMetaData;
import org.jpox.plugin.PluginManager;
import org.jpox.store.exceptions.NoTableManagedException;
import org.jpox.store.mapped.DatastoreAdapter;
import org.jpox.store.mapped.DatastoreClass;
import org.jpox.store.mapped.DatastoreContainerObject;
import org.jpox.store.mapped.MappedStoreManager;
import org.jpox.util.JPOXLogger;
import org.jpox.util.Localiser;

/**
* Base implementation of a MappingManager. Datastores should extend this to add their own specifics, and to
* add the initialisation of their supported types.
* <P>
* The idea behind a MappingManager is that at the Java side we have a series of Java type mappings,
* and at the datastore side we have a series of datastore type mappings. We need a link between the two
* to say that "this Java type can map to any of these 3 datastore types, and by default use this one".
*
* @version $Revision: 1.77 $
*/
public abstract class AbstractMappingManager implements MappingManager
{
  protected static final Localiser LOCALISER = Localiser.getInstance("org.jpox.store.Localisation",
      ObjectManagerFactoryImpl.class.getClassLoader());

    /**
     * Default constructor.
     */
    public AbstractMappingManager()
    {
    }

    /**
     * Load all datastore mappings defined in the associated plugins.
     * To be implemented by the datastore mapping managers since they have the knowledge of
     * the attributes supported by that datastore (e.g RDBMS datastores use jdbc-type, sql-type)
     * @param mgr the PluginManager
     * @param clr the ClassLoaderResolver
     * @param vendorId the datastore vendor id
     */
    public abstract void loadDatastoreMapping(PluginManager mgr, ClassLoaderResolver clr, String vendorId);

    /**
     * Accessor for the mapping for the specified class.
     * TODO Merge this with the method below, or at least say why use this or the other
     * @param c Java type
     * @param serialised Whether the type is serialised
     * @param embedded Whether the type is embedded
     * @param storeMgr Manager for the datastore
     * @param fieldName Name of the field (for logging)
     * @return The mapping for the class.
     */
    public JavaTypeMapping getMapping(Class c, boolean serialised, boolean embedded,
            MappedStoreManager storeMgr, String fieldName)
    {
        Class mc = getMappingClass(c, serialised, embedded, fieldName, storeMgr.getOMFContext().getTypeManager(),
            storeMgr.getApiAdapter());
        mc = getOverrideMappingClass(mc, null, -1); // Allow for overriding in subclasses

        JavaTypeMapping m = MappingFactory.createMapping(mc, storeMgr.getDatastoreAdapter(), c.getName());
        if (m == null)
        {
            String name = mc.getName();
            name = name.substring(name.lastIndexOf('.') + 1);

            throw new JPOXUserException(LOCALISER.msg("041012",name));
        }
        return m;
    }

    /**
     * Accessor for the mapping for the specified class.
     * Usually only called by JDOQL query expressions.
     * @param c Java type
     * @param serialised Whether the type is serialised
     * @param embedded Whether the type is embedded
     * @param storeMgr Manager for the store
     * @param clr ClassLoader resolver
     * @return The mapping for the class.
     */
    public JavaTypeMapping getMapping(Class c, boolean serialised, boolean embedded, MappedStoreManager storeMgr,
                                      ClassLoaderResolver clr)
    {
        JavaTypeMapping m;
        try
        {
            // TODO This doesnt take into account serialised/embedded
            DatastoreClass datastoreClass = storeMgr.getDatastoreClass(c.getName(), clr);
            m = datastoreClass.getIDMapping();
        }
        catch (NoTableManagedException ex)
        {
            // Note that this doesnt allow for whether a field is serialised or embedded so they get the default mapping only
            Class mc = getMappingClass(c, serialised, embedded, null, storeMgr.getOMFContext().getTypeManager(),
                storeMgr.getApiAdapter());
            mc = getOverrideMappingClass(mc, null, -1); // Allow for overriding in subclasses
            m = MappingFactory.createMapping(mc, storeMgr.getDatastoreAdapter(), c.getName());
            if (m == null)
            {
                String name = mc.getName();
                name = name.substring(name.lastIndexOf('.') + 1);

                throw new JPOXUserException(LOCALISER.msg("041012", name));
            }
            if (m instanceof SimpleDatastoreRepresentation)
            {
                createDatastoreMapping(m, storeMgr, null, m.getJavaTypeForDatastoreMapping(0));
            }
        }
        return m;
    }

    /**
     * Accessor for the mapping for the field of the specified table.
     * Can be used for fields of a class, elements of a collection of a class, elements of an array of
     * a class, keys of a map of a class, values of a map of a class. This is controlled by the final
     * argument "roleForField".
     * @param datastoreContainer Table to add the mapping to
     * @param fmd FieldMetaData for the field to map
     * @param dba Datastore adapter
     * @param clr The ClassLoaderResolver
     * @param roleForField Role that this mapping plays for the field
     * @return The mapping for the field.
     */
    public JavaTypeMapping getMapping(DatastoreContainerObject datastoreContainer,
            AbstractMemberMetaData fmd,
            DatastoreAdapter dba,
            ClassLoaderResolver clr,
            int roleForField)
    {
        Class mc = null;

        String userMappingClassName = fmd.getValueForExtension("mapping-class");
        if (userMappingClassName != null &&
            roleForField != JavaTypeMapping.MAPPING_ARRAY_ELEMENT &&
            roleForField != JavaTypeMapping.MAPPING_COLLECTION_ELEMENT &&
            roleForField != JavaTypeMapping.MAPPING_MAP_KEY &&
            roleForField != JavaTypeMapping.MAPPING_MAP_VALUE)
        {
            // User has defined their own mapping class for this field so use that
            try
            {
                mc = clr.classForName(userMappingClassName);
            }
            catch (JPOXException jpe)
            {
                throw new JPOXUserException(LOCALISER.msg("041014",
                    fmd.getFullFieldName(), userMappingClassName)).setFatal();
            }
        }
        else if (roleForField == JavaTypeMapping.MAPPING_COLLECTION_ELEMENT || roleForField == JavaTypeMapping.MAPPING_ARRAY_ELEMENT)
        {
            // Mapping a collection/array element (in a join table)
            mc = getElementMappingClass(datastoreContainer, fmd, dba, clr);
        }
        else if (roleForField == JavaTypeMapping.MAPPING_MAP_KEY)
        {
            // Mapping a map key (in a join table)
            mc = getKeyMappingClass(datastoreContainer, fmd, dba, clr);
        }
        else if (roleForField == JavaTypeMapping.MAPPING_MAP_VALUE)
        {
            // Mapping a map value (in a join table)
            mc = getValueMappingClass(datastoreContainer, fmd, dba, clr);
        }
        else
        {
            // Assumed to be a normal field
            AbstractClassMetaData acmd = null;
            if (fmd.getType().isInterface())
            {
                acmd = datastoreContainer.getStoreManager().getOMFContext().getMetaDataManager().getMetaDataForInterface(fmd.getType(), clr);
            }
            else
            {
                acmd = datastoreContainer.getStoreManager().getOMFContext().getMetaDataManager().getMetaDataForClass(fmd.getType(), clr);
            }
            MappedStoreManager storeMgr = datastoreContainer.getStoreManager();
            TypeManager typeMgr = storeMgr.getOMFContext().getTypeManager();

            if (fmd.isSerialized())
            {
                // Field is marked as serialised then we have no other option - serialise it
                mc = getMappingClass(fmd.getType(), true, false, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
            else if (fmd.getEmbeddedMetaData() != null)
            {
                // Field has an <embedded> specification so use that
                mc = getMappingClass(fmd.getType(), false, true, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
            else if (acmd != null && acmd.isEmbeddedOnly())
            {
                // If the reference type is declared with embedded only
                mc = getMappingClass(fmd.getType(), false, true, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
            else if (fmd.isEmbedded())
            {
                // Otherwise, if the field is embedded then we request that it be serialised into the owner table
                // This is particularly for java.lang.Object which should be "embedded" by default, and hence serialised
                mc = getMappingClass(fmd.getType(), true, false, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
            else
            {
                // Just get the basic mapping for the type
                mc = getMappingClass(fmd.getType(), false, false, fmd.getFullFieldName(),
                    typeMgr, storeMgr.getApiAdapter());
            }
        }
        mc = getOverrideMappingClass(mc, fmd, roleForField); // Allow for overriding in subclasses

        // Create the mapping of the selected type
        JavaTypeMapping m = MappingFactory.createMapping(mc, dba, fmd, roleForField, datastoreContainer, clr);
        if (m == null)
        {
            throw new JPOXException(LOCALISER.msg("041011", mc.getName())).setFatal();
        }

        return m;
    }

    /**
     * Convenience method to allow overriding of particular mapping classes.
     * @param mappingClass The mapping class selected
     * @param fmd Field meta data for the field (if appropriate)
     * @param roleForField Role for the field (e.g collection element)
     * @return The mapping class to use
     */
    protected Class getOverrideMappingClass(Class mappingClass, AbstractMemberMetaData fmd, int roleForField)
    {
        return mappingClass;
    }

    /**
     * Accessor for the mapping class for the specified class.
     * Provides special handling for interface types and for classes that are
     * being embedded in a field (detected using the FieldMetaData argument).
     * Refers others to its mapping manager lookup.
     * @param c Class to query
     * @param serialised Whether the field is serialised
     * @param embedded Whether the field is embedded
     * @param fieldName The full field name (for logging only)
     * @param typeMgr the TypeManager
     * @param api API Adapter
     * @return The mapping class for the class
     **/
    protected Class getMappingClass(Class c, boolean serialised, boolean embedded, String fieldName,
            TypeManager typeMgr, ApiAdapter api)
    {
        if (api.isPersistable(c))
        {
            // Persistence Capable field
            if (serialised)
            {
                // Serialised PC field
                return SerialisedPCMapping.class;
            }
            else if (embedded)
            {
                // Embedded PC field
                return EmbeddedPCMapping.class;
            }
            else
            {
                // PC field
                return PersistenceCapableMapping.class;
            }
        }

        if (c.isInterface() && !typeMgr.isSupportedType(c.getName()))
        {
            // Interface field
            if (serialised)
            {
                // Serialised Interface field
                return SerialisedReferenceMapping.class;
            }
            else if (embedded)
            {
                // Interface field
                //return InterfaceMapping.class;
                return EmbeddedPCMapping.class;
                // Embedded Interface field - anyone want to support these ? I don't ;-)
                // throw new JPOXUserException(LOCALISER.msg("041041", fieldName));
            }
            else
            {
                // Interface field
                return InterfaceMapping.class;
            }
        }

        if (c == java.lang.Object.class)
        {
            // Object field
            if (serialised)
            {
                // Serialised Object field
                return SerialisedReferenceMapping.class;
            }
            else if (embedded)
            {
                // Embedded Object field - do we ever want to support this ? I think not ;-)
                throw new JPOXUserException(LOCALISER.msg("041042", fieldName)).setFatal();
            }
            else
            {
                // Object field as reference to PC object
                return ObjectMapping.class;
            }
        }

        if (c.isArray())
        {
            // Array field
            if (api.isPersistable(c.getComponentType()))
            {
                // Array of PC objects
                return ArrayMapping.class;
            }
            else if (c.getComponentType().isInterface() && !typeMgr.isSupportedType(c.getComponentType().getName()))
            {
                // Array of interface objects
                return ArrayMapping.class;
            }
            else if (c.getComponentType() == java.lang.Object.class)
            {
                // Array of Object reference objects
                return ArrayMapping.class;
            }
            // Other array types will be caught by the default mappings
        }

        // Try the default mapping (doesnt allow for serialised setting)
        Class mappingClass = getDefaultJavaTypeMapping(typeMgr, c);
        if (mappingClass == null)
        {
            Class superClass = c.getSuperclass();
            while (superClass != null && !superClass.getName().equals(ClassNameConstants.Object) && mappingClass == null)
            {
                mappingClass = getDefaultJavaTypeMapping(typeMgr, superClass);
                superClass = superClass.getSuperclass();
            }
        }
        if (mappingClass == null)
        {
            if (typeMgr.isSupportedType(c.getName()))
            {
                // "supported" type yet no FCO mapping !
                throw new JPOXUserException(LOCALISER.msg("041001", fieldName, c.getName()));
            }
            else
            {
                Class superClass = c; // start in this class
                while (superClass!=null && !superClass.getName().equals(ClassNameConstants.Object) && mappingClass == null)
                {
                    Class[] interfaces = superClass.getInterfaces();
                    for( int i=0; i<interfaces.length && mappingClass == null; i++)
                    {
                        mappingClass = getDefaultJavaTypeMapping(typeMgr, interfaces[i]);
                    }
                    superClass = superClass.getSuperclass();
                }
                if (mappingClass == null)
                {
                    //TODO if serialised == false, should we raise an exception?
                    // Treat as serialised
                    mappingClass = SerialisedMapping.class;
                }
            }
        }
        return mappingClass;
    }

    /**
     * Convenience accessor for the mapping class of the element mapping for a collection/array of PC elements.
     * Currently only used where the collection/array elements are either serialised or embedded into a join table.
     * @param container The container
     * @param fmd MetaData for the collection field containing the collection/array of PCs
     * @param dba Database adapter
     * @param clr ClassLoader resolver
     * @return The mapping class
     */
    protected Class getElementMappingClass(DatastoreContainerObject container,
            AbstractMemberMetaData fmd,
            DatastoreAdapter dba,
            ClassLoaderResolver clr)
    {
        if (!fmd.hasCollection() && !fmd.hasArray())
        {
            // TODO Localise this message
            throw new JPOXException("Attempt to get element mapping for field " + fmd.getFullFieldName() +
                " that has no collection/array!").setFatal();
        }
        if (fmd.getJoinMetaData() == null)
        {
            throw new JPOXException("Attempt to get element mapping for field " + fmd.getFullFieldName() +
                " that has no join table defined for the collection/array").setFatal();
        }

        String userMappingClassName = null;
        if (fmd.getElementMetaData() != null)
        {
            userMappingClassName = fmd.getElementMetaData().getValueForExtension("mapping-class");
        }
        if (userMappingClassName != null)
        {
            // User has defined their own mapping class for this element so use that
            try
            {
                return clr.classForName(userMappingClassName);
            }
            catch (JPOXException jpe)
            {
                throw new JPOXUserException(LOCALISER.msg("041014", userMappingClassName)).setFatal();
            }
        }

        boolean serialised = ((fmd.hasCollection() && fmd.getCollection().isSerializedElement()) ||
            (fmd.hasArray() && fmd.getArray().isSerializedElement()));
        boolean embeddedPC = (fmd.getElementMetaData() != null && fmd.getElementMetaData().getEmbeddedMetaData() != null);
        boolean elementPC = ((fmd.hasCollection() && fmd.getCollection().getElementClassMetaData() != null) ||
            (fmd.hasArray() && fmd.getArray().getElementClassMetaData() != null));
        boolean embedded = true;
        if (fmd.hasCollection())
        {
            embedded = fmd.getCollection().isEmbeddedElement();
        }
        else if (fmd.hasArray())
        {
            embedded = fmd.getArray().isEmbeddedElement();
        }

        TypeManager typeMgr = fmd.getMetaDataManager().getOMFContext().getTypeManager();
        Class elementCls = null;
        if (fmd.hasCollection())
        {
            elementCls = clr.classForName(fmd.getCollection().getElementType());
        }
        else if (fmd.hasArray())
        {
            elementCls = clr.classForName(fmd.getArray().getElementType());
        }
        boolean elementReference = typeMgr.isReferenceType(elementCls);

        Class mc = null;
        if (serialised)
        {
            if (elementPC)
            {
                // Serialised PC element
                mc = SerialisedElementPCMapping.class;
            }
            else if (elementReference)
            {
                // Serialised Reference element
                mc = SerialisedReferenceMapping.class;
            }
            else
            {
                // Serialised Non-PC element
                mc = SerialisedMapping.class;
            }
        }
        else if (embedded)
        {
            if (embeddedPC)
            {
                // Embedded PC type
                mc = EmbeddedElementPCMapping.class;
            }
            else if (elementPC)
            {
                // "Embedded" PC type but no <embedded> so dont embed for now. Is this correct?
                mc = PersistenceCapableMapping.class;
            }
            else
            {
                // Embedded Non-PC type
                mc = getMappingClass(elementCls, serialised, embedded, fmd.getFullFieldName(),
                    typeMgr, container.getStoreManager().getApiAdapter());
            }
        }
        else
        {
            // TODO Allow for other element mappings
            throw new JPOXException("Attempt to get element mapping for field " + fmd.getFullFieldName() +
            " when not embedded or serialised - please report this to JPOX developers").setFatal();
        }

        return mc;
    }

    /**
     * Convenience accessor for the mapping class of the key mapping for a map of PC keys.
     * Currently only used where the keys are either serialised or embedded into a join table.
     * @param container The container
     * @param fmd MetaData for the field containing the map that this key is for
     * @param dba Database adapter
     * @param clr ClassLoader resolver
     * @return The mapping class
     */
    protected Class getKeyMappingClass(DatastoreContainerObject container,
            AbstractMemberMetaData fmd,
            DatastoreAdapter dba,
            ClassLoaderResolver clr)
    {
        if (fmd.getMap() == null)
        {
            throw new JPOXException("Attempt to get key mapping for field that has no map!").setFatal();
        }

        String userMappingClassName = null;
        if (fmd.getKeyMetaData() != null)
        {
            userMappingClassName = fmd.getKeyMetaData().getValueForExtension("mapping-class");
        }
        if (userMappingClassName != null)
        {
            // User has defined their own mapping class for this key so use that
            try
            {
                return clr.classForName(userMappingClassName);
            }
            catch (JPOXException jpe)
            {
                throw new JPOXUserException(LOCALISER.msg("041014", userMappingClassName)).setFatal();
            }
        }

        boolean serialised = (fmd.hasMap() && fmd.getMap().isSerializedKey());
        boolean embedded = (fmd.hasMap() && fmd.getMap().isEmbeddedKey());
        boolean embeddedPC = (fmd.getKeyMetaData() != null && fmd.getKeyMetaData().getEmbeddedMetaData() != null);
        boolean keyPC = (fmd.hasMap() && fmd.getMap().getKeyClassMetaData() != null);
        TypeManager typeMgr = fmd.getMetaDataManager().getOMFContext().getTypeManager();
        Class keyCls = clr.classForName(fmd.getMap().getKeyType());
        boolean keyReference = typeMgr.isReferenceType(keyCls);

        Class mc = null;
        if (serialised)
        {
            if (keyPC)
            {
                // Serialised PC key
                mc = SerialisedKeyPCMapping.class;
            }
            else if (keyReference)
            {
                // Serialised Reference key
                mc = SerialisedReferenceMapping.class;
            }
            else
            {
                // Serialised Non-PC element
                mc = SerialisedMapping.class;
            }
        }
        else if (embedded)
        {
            if (embeddedPC)
            {
                // Embedded PC key
                mc = EmbeddedKeyPCMapping.class;
            }
            else if (keyPC)
            {
                // "Embedded" PC type but no <embedded> so dont embed for now. Is this correct?
                mc = PersistenceCapableMapping.class;
            }
            else
            {
                // Embedded Non-PC type
                mc = getMappingClass(keyCls, serialised, embedded, fmd.getFullFieldName(), typeMgr,
                    container.getStoreManager().getApiAdapter());
            }
        }
        else
        {
            // TODO Allow for other key mappings
            throw new JPOXException("Attempt to get key mapping for field " + fmd.getFullFieldName() +
                " when not embedded or serialised - please report this to JPOX developers").setFatal();
        }

        return mc;
    }

    /**
     * Convenience accessor for the mapping class of the value mapping for a map of PC values.
     * Currently only used where the value are either serialised or embedded into a join table.
     * @param container The container
     * @param fmd MetaData for the field containing the map that this value is for
     * @param dba Database adapter
     * @param clr ClassLoader resolver
     * @return The mapping class
     */
    protected Class getValueMappingClass(DatastoreContainerObject container,
            AbstractMemberMetaData fmd,
            DatastoreAdapter dba,
            ClassLoaderResolver clr)
    {
        if (fmd.getMap() == null)
        {
            throw new JPOXException("Attempt to get value mapping for field that has no map!").setFatal();
        }

        String userMappingClassName = null;
        if (fmd.getValueMetaData() != null)
        {
            userMappingClassName = fmd.getValueMetaData().getValueForExtension("mapping-class");
        }
        if (userMappingClassName != null)
        {
            // User has defined their own mapping class for this value so use that
            try
            {
                return clr.classForName(userMappingClassName);
            }
            catch (JPOXException jpe)
            {
                throw new JPOXUserException(LOCALISER.msg("041014", userMappingClassName)).setFatal();
            }
        }

        boolean serialised = (fmd.hasMap() && fmd.getMap().isSerializedValue());
        boolean embedded = (fmd.hasMap() && fmd.getMap().isEmbeddedValue());
        boolean embeddedPC = (fmd.getValueMetaData() != null && fmd.getValueMetaData().getEmbeddedMetaData() != null);
        boolean valuePC = (fmd.hasMap() && fmd.getMap().getValueClassMetaData() != null);
        TypeManager typeMgr = fmd.getMetaDataManager().getOMFContext().getTypeManager();
        Class valueCls = clr.classForName(fmd.getMap().getValueType());
        boolean valueReference = typeMgr.isReferenceType(valueCls);

        Class mc = null;
        if (serialised)
        {
            if (valuePC)
            {
                // Serialised PC value
                mc = SerialisedValuePCMapping.class;
            }
            else if (valueReference)
            {
                // Serialised Reference value
                mc = SerialisedReferenceMapping.class;
            }
            else
            {
                // Serialised Non-PC element
                mc = SerialisedMapping.class;
            }
        }
        else if (embedded)
        {
            if (embeddedPC)
            {
                // Embedded PC key
                mc = EmbeddedValuePCMapping.class;
            }
            else if (valuePC)
            {
                // "Embedded" PC type but no <embedded> so dont embed for now. Is this correct?
                mc = PersistenceCapableMapping.class;
            }
            else
            {
                // Embedded Non-PC type
                mc = getMappingClass(valueCls, serialised, embedded, fmd.getFullFieldName(), typeMgr,
                    container.getStoreManager().getApiAdapter());
            }
        }
        else
        {
            // TODO Allow for other value mappings
            throw new JPOXException("Attempt to get value mapping for field " + fmd.getFullFieldName() +
                " when not embedded or serialised - please report this to JPOX developers").setFatal();
        }

        return mc;
    }

    /**
     * Method to return the default java type mapping class for a specified java type.
     * @param javaType java type
     * @param typeMgr the TypeManager
     * @return The mapping class to use (by default)
     */
    protected Class getDefaultJavaTypeMapping(TypeManager typeMgr, Class javaType)
    {
        Class cls = typeMgr.getMappingType(javaType.getName());       
        if (cls == null)
        {
          JPOXLogger.PERSISTENCE.debug(LOCALISER.msg("041000", javaType.getName()));
          return null;
        }
        return cls;
    }
   
    /**
     * Utility to register a datastore mapping for a java type, and the SQL/JDBC types it can be mapped to.
     * This can also be called to change the default setting of a mapping - just supply the same
     * values of java/JDBC/SQL types and a different default value
     * @param javaTypeName Name of the java type
     * @param datastoreMappingType The datastore mapping
     * @param jdbcType The JDBC type that can be used
     * @param sqlType The SQL type that can be used
     * @param dflt Whether this type should be used as the default mapping for this Java type
     */
    public abstract void registerDatastoreMapping(String javaTypeName, Class datastoreMappingType, String jdbcType, String sqlType, boolean dflt);
   
    protected class TypeMapping
    {
        Class javaMappingType;
       
        boolean isDefault;
       
        /**
         * Constructor
         * @param javaMappingType Mapping type to use for thie java type
         * @param isDefault Whether it is the default mapping for this java type
         */
        public TypeMapping(Class javaMappingType, boolean isDefault)
        {
            this.javaMappingType = javaMappingType;
            this.isDefault = isDefault;
        }
       
        /**
         * @return Returns the isDefault.
         */
        public boolean isDefault()
        {
            return isDefault;
        }
       
        /**
         * Mutator for whether this is the default datastore mapping for the mapping
         * @param isDefault Whether it is the default.
         */
        public void setDefault(boolean isDefault)
        {
            this.isDefault = isDefault;
        }
       
        /**
         * @return Returns the mappingType.
         */
        public Class getMappingType()
        {
            return javaMappingType;
        }
    }
}
TOP

Related Classes of org.jpox.store.mapped.mapping.AbstractMappingManager$TypeMapping

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.