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 ColumnMappinggetColumnMapping(int index)Accessor for a column mappingColumnMapping[]getColumnMappings()Accessor for the column mappings for this java typeClassgetJavaType()Accessor for the java type being mapped.StringgetJavaTypeForColumnMapping(int index)Accessor for the name of the java-type actually used when mapping the particular column.intgetNumberOfColumnMappings()Accessor for the number of column mappings.ObjectgetObject(org.datanucleus.ExecutionContext ec, ResultSet rs, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.ObjectgetObject(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 byexprIndexbased on being embedded/serialised into the provided owner.JavaTypeMappinggetWrappedMapping()booleanhasSimpleDatastoreRepresentation()Whether the mapping has a simple (single column) datastore representation.booleanincludeInFetchStatement()Accessor for whether this mapping is to be included in any fetch statement.voidinitialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)Initialize this JavaTypeMapping for the supplied table and field/property metadata.voidpostFetch(org.datanucleus.state.DNStateManager sm)Method called after the retrieval of the object, so that additional operations can be performed if necessary.voidpostInsert(org.datanucleus.state.DNStateManager sm)Method called after the insert of the object so that additional operations can be performed if necessary.voidpostUpdate(org.datanucleus.state.DNStateManager sm)Method called after the update of the object, so that additional operations can be performed if necessary.voidpreDelete(org.datanucleus.state.DNStateManager sm)Method called before the delete of objects, so that additional operations can be performed if necessary.voidsetMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData mmd)Method to set the metadata of the member for which this mapping applies.voidsetObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] pos, Object container)Sets avalueintodatastoreStatementat 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:JavaTypeMappingInitialize 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:
initializein 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:JavaTypeMappingMethod 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:
setMemberMetaDatain classJavaTypeMapping- Parameters:
mmd- Field/Property MetaData
-
getWrappedMapping
public JavaTypeMapping getWrappedMapping()
-
includeInFetchStatement
public boolean includeInFetchStatement()
Description copied from class:JavaTypeMappingAccessor for whether this mapping is to be included in any fetch statement.- Overrides:
includeInFetchStatementin classJavaTypeMapping- Returns:
- Whether to include this mapping in a fetch statement
-
hasSimpleDatastoreRepresentation
public boolean hasSimpleDatastoreRepresentation()
Description copied from class:JavaTypeMappingWhether the mapping has a simple (single column) datastore representation.- Overrides:
hasSimpleDatastoreRepresentationin 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setObjectin 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getObjectin 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:JavaTypeMappingObtains a value from the result set at position specified byexprIndexbased on being embedded/serialised into the provided owner.- Overrides:
getObjectin 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:JavaTypeMappingAccessor for the number of column mappings.- Overrides:
getNumberOfColumnMappingsin classJavaTypeMapping- Returns:
- the number of column mappings
-
getColumnMappings
public ColumnMapping[] getColumnMappings()
Description copied from class:JavaTypeMappingAccessor for the column mappings for this java type- Overrides:
getColumnMappingsin classJavaTypeMapping- Returns:
- The column mapping(s)
-
getColumnMapping
public ColumnMapping getColumnMapping(int index)
Description copied from class:JavaTypeMappingAccessor for a column mapping- Overrides:
getColumnMappingin classJavaTypeMapping- Parameters:
index- The id of the column- Returns:
- The column mapping
-
getJavaTypeForColumnMapping
public String getJavaTypeForColumnMapping(int index)
Description copied from class:JavaTypeMappingAccessor 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:
getJavaTypeForColumnMappingin 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:MappingCallbacksMethod called after the insert of the object so that additional operations can be performed if necessary.- Specified by:
postInsertin interfaceMappingCallbacks- Parameters:
sm- StateManager of the owner
-
postFetch
public void postFetch(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacksMethod called after the retrieval of the object, so that additional operations can be performed if necessary.- Specified by:
postFetchin interfaceMappingCallbacks- Parameters:
sm- StateManager of the owner
-
postUpdate
public void postUpdate(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacksMethod called after the update of the object, so that additional operations can be performed if necessary.- Specified by:
postUpdatein interfaceMappingCallbacks- Parameters:
sm- StateManager of the owner
-
preDelete
public void preDelete(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacksMethod called before the delete of objects, so that additional operations can be performed if necessary.- Specified by:
preDeletein interfaceMappingCallbacks- Parameters:
sm- StateManager of the owner
-
getJavaType
public Class getJavaType()
Description copied from class:JavaTypeMappingAccessor 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:
getJavaTypein classJavaTypeMapping- Returns:
- The java type
-
-