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
Maps single collection elements as 1-1 instead of 1-N, by wrapping and reusing the JavaTypeMappings and member metadata of the element types.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetColumnMapping(int index) Accessor for a column mappingAccessor for the column mappings for this java typeAccessor for the java type being mapped.getJavaTypeForColumnMapping(int index) Accessor for the name of the java-type actually used when mapping the particular column.intAccessor for the number of column mappings.Obtains a value fromdatastoreResultsat position specified byexprIndex.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 byexprIndexbased on being embedded/serialised into the provided owner.booleanWhether the mapping has a simple (single column) datastore representation.booleanAccessor 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 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
-
Field Details
-
wrappedMapping
-
wrappedTypeClass
-
-
Constructor Details
-
SingleCollectionMapping
public SingleCollectionMapping()
-
-
Method Details
-
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
-
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
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
Description copied from class:JavaTypeMappingAccessor for the column mappings for this java type- Overrides:
getColumnMappingsin classJavaTypeMapping- Returns:
- The column mapping(s)
-
getColumnMapping
Description copied from class:JavaTypeMappingAccessor for a column mapping- Overrides:
getColumnMappingin classJavaTypeMapping- Parameters:
index- The id of the column- Returns:
- The column mapping
-
getJavaTypeForColumnMapping
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
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
-