Class MappingManagerImpl
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
MappingManagerImpl.MappingConverterDetails
-
Field Summary
Fields Modifier and Type Field Description protected org.datanucleus.ClassLoaderResolver
clr
protected Map<String,org.datanucleus.store.rdbms.mapping.MappingManagerImpl.MappedType>
mappedTypes
The mapped types, keyed by the class name.protected RDBMSStoreManager
storeMgr
-
Fields inherited from interface org.datanucleus.store.rdbms.mapping.MappingManager
METADATA_EXTENSION_INSERT_FUNCTION, METADATA_EXTENSION_SELECT_FUNCTION, METADATA_EXTENSION_UPDATE_FUNCTION
-
-
Constructor Summary
Constructors Constructor Description MappingManagerImpl(RDBMSStoreManager storeMgr)
Constructor for a mapping manager for an RDBMS datastore.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addMappedType(Class javaType, Class<? extends JavaTypeMapping> mappingType)
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.Column
createColumn(JavaTypeMapping mapping, String javaType, int columnIndex)
Method to create a column for a Java type mapping.Column
createColumn(JavaTypeMapping mapping, String javaType, org.datanucleus.metadata.ColumnMetaData colmd)
Method to create a column for a Java type mapping.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.ColumnMapping
createColumnMapping(JavaTypeMapping mapping, Column column, String javaType)
Method to create the column mapping for a particular column and java type.protected org.datanucleus.store.rdbms.mapping.MappingManagerImpl.MappedType
findMappedTypeForClass(Class javaType)
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.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.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.JavaTypeMapping
getMapping(Class javaType)
Accessor for the mapping for the specified class.JavaTypeMapping
getMapping(Class javaType, boolean serialised, boolean embedded, String fieldName)
Accessor for the mapping for the specified class.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.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.Class<? extends JavaTypeMapping>
getMappingType(String javaTypeName)
Accessor for the JavaTypeMapping class for the supplied java type.JavaTypeMapping
getMappingWithColumnMapping(Class javaType, boolean serialised, boolean embedded, org.datanucleus.ClassLoaderResolver clr)
Accessor for the mapping for the specified class.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.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.boolean
isSupportedMappedType(String javaTypeName)
Accessor for whether a java type is supported as being mappable.
-
-
-
Field Detail
-
storeMgr
protected final RDBMSStoreManager storeMgr
-
clr
protected final org.datanucleus.ClassLoaderResolver clr
-
-
Constructor Detail
-
MappingManagerImpl
public MappingManagerImpl(RDBMSStoreManager storeMgr)
Constructor for a mapping manager for an RDBMS datastore.- Parameters:
storeMgr
- The StoreManager
-
-
Method Detail
-
addMappedType
protected void addMappedType(Class javaType, Class<? extends JavaTypeMapping> mappingType)
-
isSupportedMappedType
public boolean isSupportedMappedType(String javaTypeName)
Accessor for whether a java type is supported as being mappable.- Specified by:
isSupportedMappedType
in interfaceMappingManager
- 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 interfaceMappingManager
- 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 interfaceMappingManager
- Parameters:
javaType
- Java typeserialised
- Whether the type is serialisedembedded
- Whether the type is embeddedclr
- 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 interfaceMappingManager
- 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 interfaceMappingManager
- Parameters:
javaType
- Java typeserialised
- Whether the type is serialisedembedded
- Whether the type is embeddedfieldName
- 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 interfaceMappingManager
- Parameters:
table
- Table to add the mapping tommd
- MetaData for the member to mapclr
- The ClassLoaderResolverfieldRole
- 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 selectedmmd
- 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 queryserialised
- Whether the field is serialisedembedded
- Whether the field is embeddedcolmds
- 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 tablemmd
- MetaData for the collection member containing the collection/array of PCsfieldRole
- role of this mapping for this memberclr
- 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 containermmd
- MetaData for the field containing the map that this key is forclr
- 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 containermmd
- MetaData for the field/property containing the map that this value is forclr
- 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 typecolmds
- 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 interfaceMappingManager
- Parameters:
mapping
- The java mappingmmd
- MetaData for the field/propertyindex
- Index of the columncolumn
- 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 interfaceMappingManager
- Parameters:
mapping
- The java mappingcolumn
- 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 interfaceMappingManager
- Parameters:
mapping
- Java type mapping for the fieldjavaType
- The type of field being stored in this columncolumnIndex
- 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 interfaceMappingManager
- Parameters:
mapping
- Java type mapping for the fieldjavaType
- The type of field being stored in this columncolmd
- 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 interfaceMappingManager
- Parameters:
mmd
- MetaData for the field whose mapping it istable
- Datastore class where we create the columnmapping
- The Java type for this fieldcolmd
- The columnMetaData for this columnreference
- The column we are referencingclr
- ClassLoader resolver- Returns:
- The column
-
-