Class SingleCollectionMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
-
- org.datanucleus.store.rdbms.mapping.java.SingleCollectionMapping
-
- All Implemented Interfaces:
MappingCallbacks
- Direct Known Subclasses:
OptionalMapping
public class SingleCollectionMapping extends JavaTypeMapping implements MappingCallbacks
Maps single collection elements as 1-1 instead of 1-N, by wrapping and reusing the JavaTypeMappings and member metadata of the element types.
-
-
Field Summary
-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type
-
-
Constructor Summary
Constructors Constructor Description SingleCollectionMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ColumnMapping
getColumnMapping(int index)
Accessor for a column mappingColumnMapping[]
getColumnMappings()
Accessor for the column mappings for this java typeClass
getJavaType()
Accessor for the java type being mapped.String
getJavaTypeForColumnMapping(int index)
Accessor for the name of the java-type actually used when mapping the particular column.int
getNumberOfColumnMappings()
Accessor for the number of column mappings.Object
getObject(org.datanucleus.ExecutionContext ec, ResultSet rs, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.Object
getObject(org.datanucleus.ExecutionContext ec, ResultSet rs, int[] exprIndex, org.datanucleus.state.DNStateManager ownerSM, int ownerFieldNumber)
Obtains a value from the result set at position specified byexprIndex
based on being embedded/serialised into the provided owner.JavaTypeMapping
getWrappedMapping()
boolean
hasSimpleDatastoreRepresentation()
Whether the mapping has a simple (single column) datastore representation.boolean
includeInFetchStatement()
Accessor for whether this mapping is to be included in any fetch statement.void
initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)
Initialize this JavaTypeMapping for the supplied table and field/property metadata.void
postFetch(org.datanucleus.state.DNStateManager sm)
Method called after the retrieval of the object, so that additional operations can be performed if necessary.void
postInsert(org.datanucleus.state.DNStateManager sm)
Method called after the insert of the object so that additional operations can be performed if necessary.void
postUpdate(org.datanucleus.state.DNStateManager sm)
Method called after the update of the object, so that additional operations can be performed if necessary.void
preDelete(org.datanucleus.state.DNStateManager sm)
Method called before the delete of objects, so that additional operations can be performed if necessary.void
setMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Method to set the metadata of the member for which this mapping applies.void
setObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] pos, Object container)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
addColumnMapping, equals, failureMessage, getAbsoluteFieldNumber, getBoolean, getByte, getChar, getColumnMetaDataForMember, getDouble, getFloat, getInt, getLong, getMemberMetaData, getReferenceMapping, getRoleForMember, getShort, getStoreManager, getString, getTable, getType, getValueForColumnMapping, hashCode, includeInInsertStatement, includeInUpdateStatement, initialize, isNullable, isSerialised, performSetPostProcessing, representableAsStringLiteralInStatement, requiresSetPostProcessing, setAbsFieldNumber, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setObject, setReferenceMapping, setRoleForMember, setShort, setString, setTable
-
-
-
-
Method Detail
-
initialize
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)
Description copied from class:JavaTypeMapping
Initialize this JavaTypeMapping for the supplied table and field/property metadata. Subclasses should override this method to perform any datastore initialization operations. Assumes the "roleForMember" is already set- Overrides:
initialize
in classJavaTypeMapping
- Parameters:
mmd
- MetaData for the field/property to be mapped (if any)table
- The table storing this mapping (if any)clr
- the ClassLoaderResolver
-
setMemberMetaData
public void setMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Description copied from class:JavaTypeMapping
Method to set the metadata of the member for which this mapping applies. For use where the mapping was created for a particular type (using the initialize(StoreManager, String) and we now have the member that it applies for.- Overrides:
setMemberMetaData
in classJavaTypeMapping
- Parameters:
mmd
- Field/Property MetaData
-
getWrappedMapping
public JavaTypeMapping getWrappedMapping()
-
includeInFetchStatement
public boolean includeInFetchStatement()
Description copied from class:JavaTypeMapping
Accessor for whether this mapping is to be included in any fetch statement.- Overrides:
includeInFetchStatement
in classJavaTypeMapping
- Returns:
- Whether to include this mapping in a fetch statement
-
hasSimpleDatastoreRepresentation
public boolean hasSimpleDatastoreRepresentation()
Description copied from class:JavaTypeMapping
Whether the mapping has a simple (single column) datastore representation.- Overrides:
hasSimpleDatastoreRepresentation
in classJavaTypeMapping
- Returns:
- Whether it has a simple datastore representation (single column)
-
setObject
public void setObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] pos, Object container)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setObject
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementpos
- the position of the value in the statementcontainer
- the value
-
getObject
public Object getObject(org.datanucleus.ExecutionContext ec, ResultSet rs, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getObject
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextrs
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
getObject
public Object getObject(org.datanucleus.ExecutionContext ec, ResultSet rs, int[] exprIndex, org.datanucleus.state.DNStateManager ownerSM, int ownerFieldNumber)
Description copied from class:JavaTypeMapping
Obtains a value from the result set at position specified byexprIndex
based on being embedded/serialised into the provided owner.- Overrides:
getObject
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextrs
- an object returned from the datastore with valuesexprIndex
- the position of the value in the result setownerSM
- the owner StateManager where this is embeddedownerFieldNumber
- the owner field number where this is embedded- Returns:
- the value
-
getNumberOfColumnMappings
public int getNumberOfColumnMappings()
Description copied from class:JavaTypeMapping
Accessor for the number of column mappings.- Overrides:
getNumberOfColumnMappings
in classJavaTypeMapping
- Returns:
- the number of column mappings
-
getColumnMappings
public ColumnMapping[] getColumnMappings()
Description copied from class:JavaTypeMapping
Accessor for the column mappings for this java type- Overrides:
getColumnMappings
in classJavaTypeMapping
- Returns:
- The column mapping(s)
-
getColumnMapping
public ColumnMapping getColumnMapping(int index)
Description copied from class:JavaTypeMapping
Accessor for a column mapping- Overrides:
getColumnMapping
in classJavaTypeMapping
- Parameters:
index
- The id of the column- Returns:
- The column mapping
-
getJavaTypeForColumnMapping
public String getJavaTypeForColumnMapping(int index)
Description copied from class:JavaTypeMapping
Accessor for the name of the java-type actually used when mapping the particular column. This java-type must have an entry in the column mappings. The default implementation throws an UnsupportedOperationException.- Overrides:
getJavaTypeForColumnMapping
in classJavaTypeMapping
- Parameters:
index
- requested column index.- Returns:
- the name of java-type for the requested column.
-
postInsert
public void postInsert(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacks
Method called after the insert of the object so that additional operations can be performed if necessary.- Specified by:
postInsert
in interfaceMappingCallbacks
- Parameters:
sm
- StateManager of the owner
-
postFetch
public void postFetch(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacks
Method called after the retrieval of the object, so that additional operations can be performed if necessary.- Specified by:
postFetch
in interfaceMappingCallbacks
- Parameters:
sm
- StateManager of the owner
-
postUpdate
public void postUpdate(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacks
Method called after the update of the object, so that additional operations can be performed if necessary.- Specified by:
postUpdate
in interfaceMappingCallbacks
- Parameters:
sm
- StateManager of the owner
-
preDelete
public void preDelete(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacks
Method called before the delete of objects, so that additional operations can be performed if necessary.- Specified by:
preDelete
in interfaceMappingCallbacks
- Parameters:
sm
- StateManager of the owner
-
getJavaType
public Class getJavaType()
Description copied from class:JavaTypeMapping
Accessor for the java type being mapped. This is the java type that the mapping represents. Some examples :- if the field is of type "MyClass" then the mapping will be OIDMapping (or subclass) the javaType will be OID, and the type will be MyClass.
- if the field is of type "int" then the mapping will be IntegerMapping, the javaType will be Integer, and the type will be int.
- Specified by:
getJavaType
in classJavaTypeMapping
- Returns:
- The java type
-
-