Class MappingManagerImpl

  • All Implemented Interfaces:
    MappingManager
    Direct Known Subclasses:
    OracleMappingManagerImpl

    public class MappingManagerImpl
    extends Object
    implements MappingManager
    Default Mapping manager implementation. Provides mappings from standard Java types (defined in org.datanucleus.store.rdbms.mapping.java) to datastore mappings for JDBC types (defined in org.datanucleus.store.rdbms.mapping.column).
    • Field Detail

      • clr

        protected final org.datanucleus.ClassLoaderResolver clr
      • mappedTypes

        protected Map<String,​org.datanucleus.store.rdbms.mapping.MappingManagerImpl.MappedType> mappedTypes
        The mapped types, keyed by the class name.
    • Constructor Detail

      • MappingManagerImpl

        public MappingManagerImpl​(RDBMSStoreManager storeMgr)
        Constructor for a mapping manager for an RDBMS datastore.
        Parameters:
        storeMgr - The StoreManager
    • Method Detail

      • isSupportedMappedType

        public boolean isSupportedMappedType​(String javaTypeName)
        Accessor for whether a java type is supported as being mappable.
        Specified by:
        isSupportedMappedType in interface MappingManager
        Parameters:
        javaTypeName - The java type name
        Returns:
        Whether the class is supported (to some degree)
      • getMappingType

        public Class<? extends JavaTypeMapping> getMappingType​(String javaTypeName)
        Accessor for the JavaTypeMapping class for the supplied java type.
        Specified by:
        getMappingType in interface MappingManager
        Parameters:
        javaTypeName - The java type name
        Returns:
        The Java mapping type
      • findMappedTypeForClass

        protected org.datanucleus.store.rdbms.mapping.MappingManagerImpl.MappedType findMappedTypeForClass​(Class javaType)
      • getMappingWithColumnMapping

        public JavaTypeMapping getMappingWithColumnMapping​(Class javaType,
                                                           boolean serialised,
                                                           boolean embedded,
                                                           org.datanucleus.ClassLoaderResolver clr)
        Accessor for the mapping for the specified class. Usually only called by JDOQL query expressions. If the type has its own table returns the id mapping of the table. If the type doesn't have its own table then creates the mapping and, if it has a simple datastore representation, creates the column mapping. The JavaTypeMapping has no metadata/table associated.
        Specified by:
        getMappingWithColumnMapping in interface MappingManager
        Parameters:
        javaType - Java type
        serialised - Whether the type is serialised
        embedded - Whether the type is embedded
        clr - ClassLoader resolver
        Returns:
        The mapping for the class.
      • getMapping

        public JavaTypeMapping getMapping​(Class javaType)
        Accessor for the mapping for the specified class. This simply creates a JavaTypeMapping for the java type and returns it. The mapping has no underlying datastore mapping(s) and no associated field/table.
        Specified by:
        getMapping in interface MappingManager
        Parameters:
        javaType - Java type
        Returns:
        The mapping for the class.
      • getMapping

        public JavaTypeMapping getMapping​(Class javaType,
                                          boolean serialised,
                                          boolean embedded,
                                          String fieldName)
        Accessor for the mapping for the specified class. This simply creates a JavaTypeMapping for the java type and returns it. The mapping has no underlying datastore mapping(s) and no associated field/table.
        Specified by:
        getMapping in interface MappingManager
        Parameters:
        javaType - Java type
        serialised - Whether the type is serialised
        embedded - Whether the type is embedded
        fieldName - Name of the field (for logging)
        Returns:
        The mapping for the class.
      • getMapping

        public JavaTypeMapping getMapping​(Table table,
                                          org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                          org.datanucleus.ClassLoaderResolver clr,
                                          org.datanucleus.metadata.FieldRole fieldRole)
        Accessor for the mapping for the member of the specified table. Can be used for members of a class, element of a collection of a class, element 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 role argument.
        Specified by:
        getMapping in interface MappingManager
        Parameters:
        table - Table to add the mapping to
        mmd - MetaData for the member to map
        clr - The ClassLoaderResolver
        fieldRole - Role that this mapping plays for the field
        Returns:
        The mapping for the member.
      • getOverrideMappingClass

        protected Class<? extends JavaTypeMapping> getOverrideMappingClass​(Class<? extends JavaTypeMapping> mappingClass,
                                                                           org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                           org.datanucleus.metadata.FieldRole fieldRole)
        Convenience method to allow overriding of particular mapping classes. This is currently only required for Oracle due to non-standard BLOB handlers.
        Parameters:
        mappingClass - The mapping class selected
        mmd - Meta data for the member (if appropriate)
        fieldRole - Role for the field (e.g collection element)
        Returns:
        The mapping class to use
      • getMappingClass

        protected MappingManagerImpl.MappingConverterDetails getMappingClass​(Class javaType,
                                                                             boolean serialised,
                                                                             boolean embedded,
                                                                             org.datanucleus.metadata.ColumnMetaData[] colmds,
                                                                             String fieldName)
        Accessor for the mapping class for the specified type. Provides special handling for interface types and for classes that are being embedded in a field. Refers others to its mapping manager lookup.
        Parameters:
        javaType - Class to query
        serialised - Whether the field is serialised
        embedded - Whether the field is embedded
        colmds - Metadata for column(s) (optional)
        fieldName - The full field name (for logging only)
        Returns:
        The mapping class for the class
      • getElementMapping

        protected JavaTypeMapping getElementMapping​(Table table,
                                                    org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                    org.datanucleus.metadata.FieldRole fieldRole,
                                                    org.datanucleus.ClassLoaderResolver clr)
        Convenience accessor for the element mapping for the element of a collection/array of elements.
        Parameters:
        table - The table
        mmd - MetaData for the collection member containing the collection/array of PCs
        fieldRole - role of this mapping for this member
        clr - ClassLoader resolver
        Returns:
        The mapping
      • getKeyMapping

        protected JavaTypeMapping getKeyMapping​(Table table,
                                                org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                org.datanucleus.ClassLoaderResolver clr)
        Convenience accessor for the mapping of the key of a map.
        Parameters:
        table - The container
        mmd - MetaData for the field containing the map that this key is for
        clr - ClassLoader resolver
        Returns:
        The mapping
      • getValueMapping

        protected JavaTypeMapping getValueMapping​(Table table,
                                                  org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                  org.datanucleus.ClassLoaderResolver clr)
        Convenience accessor for the mapping of the value for a map.
        Parameters:
        table - The container
        mmd - MetaData for the field/property containing the map that this value is for
        clr - ClassLoader resolver
        Returns:
        The mapping
      • getDefaultJavaTypeMapping

        protected MappingManagerImpl.MappingConverterDetails getDefaultJavaTypeMapping​(Class javaType,
                                                                                       org.datanucleus.metadata.ColumnMetaData[] colmds)
        Method to return the default java type mapping class for a specified java type.
        Parameters:
        javaType - java type
        colmds - Metadata for the column(s) (optional)
        Returns:
        The mapping class to use (by default)
      • createColumnMapping

        public ColumnMapping createColumnMapping​(JavaTypeMapping mapping,
                                                 org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                 int index,
                                                 Column column)
        Method to create the column mapping for a java type mapping at a particular index.
        Specified by:
        createColumnMapping in interface MappingManager
        Parameters:
        mapping - The java mapping
        mmd - MetaData for the field/property
        index - Index of the column
        column - The column
        Returns:
        The column mapping
      • createColumnMapping

        public ColumnMapping createColumnMapping​(JavaTypeMapping mapping,
                                                 Column column,
                                                 String javaType)
        Method to create the column mapping for a particular column and java type. If the column is specified it is linked to the created column mapping.
        Specified by:
        createColumnMapping in interface MappingManager
        Parameters:
        mapping - The java mapping
        column - The column (can be null)
        javaType - The java type
        Returns:
        The column mapping
      • createColumn

        public Column createColumn​(JavaTypeMapping mapping,
                                   String javaType,
                                   int columnIndex)
        Method to create a column for a Java type mapping. This is NOT used for persistable mappings - see method below.
        Specified by:
        createColumn in interface MappingManager
        Parameters:
        mapping - Java type mapping for the field
        javaType - The type of field being stored in this column
        columnIndex - Index of the column to use
        Returns:
        The column
      • createColumn

        public Column createColumn​(JavaTypeMapping mapping,
                                   String javaType,
                                   org.datanucleus.metadata.ColumnMetaData colmd)
        Method to create a column for a Java type mapping. This is used for serialised PC elements/keys/values in a join table. TODO Merge this with the method above.
        Specified by:
        createColumn in interface MappingManager
        Parameters:
        mapping - Java type mapping for the field
        javaType - The type of field being stored in this column
        colmd - MetaData for the column
        Returns:
        The column
      • createColumn

        public Column createColumn​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                   Table table,
                                   JavaTypeMapping mapping,
                                   org.datanucleus.metadata.ColumnMetaData colmd,
                                   Column reference,
                                   org.datanucleus.ClassLoaderResolver clr)
        Method to create a column for a persistable mapping.
        Specified by:
        createColumn in interface MappingManager
        Parameters:
        mmd - MetaData for the field whose mapping it is
        table - Datastore class where we create the column
        mapping - The Java type for this field
        colmd - The columnMetaData for this column
        reference - The column we are referencing
        clr - ClassLoader resolver
        Returns:
        The column