Class AbstractContainerMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
-
- org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
-
- org.datanucleus.store.rdbms.mapping.java.AbstractContainerMapping
-
- Direct Known Subclasses:
ArrayMapping,CollectionMapping,MapMapping
public abstract class AbstractContainerMapping extends SingleFieldMapping
Mapping for a field that represents a container of objects, such as a List, a Set, a Collection, a Map, or an array. Has an owner table. Can be represented in the following ways :-- Using a Join-Table, where the linkage between owner and elements/keys/values is stored in this table
- Using a Foreign-Key in the element/key/value
- Embedded into the Join-Table
- Serialised into a single-column in the Join-Table
- In a single column in the owner table, using serialisation
- In a single column in the owner table, using a converter
-
-
Field Summary
-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
EXTENSION_CHECK_CONSTRAINT_VALUES
-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type
-
-
Constructor Summary
Constructors Constructor Description AbstractContainerMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancontainerIsStoredInSingleColumn()Convenience method to return if the container (collection or map) is stored in the owning table as a column.ColumnMappinggetColumnMapping(int index)Accessor for a datastore mappingColumnMapping[]getColumnMappings()Accessor for the datastore mappings for this java typeStringgetJavaTypeForColumnMapping(int index)Accessor for the name of the java-type actually used when mapping the particular column.intgetNumberOfColumnMappings()Accessor for the number of columnsObjectgetObject(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Method to retrieve an object from the passed JDBC ResultSet.TablegetTable()Accessor for the datastore class.booleanhasSimpleDatastoreRepresentation()Whether the mapping has a simple (single column) datastore representation.booleanincludeInFetchStatement()This mapping is included in the select statement.booleanincludeInInsertStatement()This mapping is included in the insert statement.booleanincludeInUpdateStatement()This mapping is included in the update statement.voidinitialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)Initialize this JavaTypeMapping for the given field/property.voidpostFetch(org.datanucleus.state.DNStateManager sm)Method to be called after any fetch of the owner class element.protected voidprepareColumnMapping()Method to prepare a column mapping for use in the datastore.protected org.datanucleus.store.types.SCOreplaceFieldWithWrapper(org.datanucleus.state.DNStateManager sm, Object value)Method to replace the field that this mapping represents with a SCO wrapper.voidsetObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value)Method to set a field in the passed JDBC PreparedStatement using this mapping.-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
getBoolean, getByte, getChar, getDefaultLength, getDouble, getFloat, getInt, getLong, getShort, getString, getValidValues, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setString
-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
addColumnMapping, equals, failureMessage, getAbsoluteFieldNumber, getColumnMetaDataForMember, getJavaType, getMemberMetaData, getObject, getReferenceMapping, getRoleForMember, getStoreManager, getType, getValueForColumnMapping, hashCode, initialize, isNullable, isSerialised, performSetPostProcessing, representableAsStringLiteralInStatement, requiresSetPostProcessing, setAbsFieldNumber, setMemberMetaData, setObject, setReferenceMapping, setRoleForMember, setTable
-
-
-
-
Method Detail
-
initialize
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)Initialize this JavaTypeMapping for the given field/property.- Overrides:
initializein classSingleFieldMapping- Parameters:
mmd- MetaData for the field/property to be mapped (if any)table- The datastore container storing this mapping (if any)clr- the ClassLoaderResolver
-
hasSimpleDatastoreRepresentation
public boolean hasSimpleDatastoreRepresentation()
Whether the mapping has a simple (single column) datastore representation.- Overrides:
hasSimpleDatastoreRepresentationin classJavaTypeMapping- Returns:
- Whether it has a simple datastore representation (single column)
-
prepareColumnMapping
protected void prepareColumnMapping()
Method to prepare a column mapping for use in the datastore. This creates the column in the table.- Overrides:
prepareColumnMappingin classSingleFieldMapping
-
getJavaTypeForColumnMapping
public String getJavaTypeForColumnMapping(int index)
Accessor for the name of the java-type actually used when mapping the particular column. This java-type must have an entry in the datastore mappings.- Overrides:
getJavaTypeForColumnMappingin classSingleFieldMapping- Parameters:
index- requested column index.- Returns:
- the name of java-type for the requested column.
-
setObject
public void setObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value)Method to set a field in the passed JDBC PreparedStatement using this mapping. Only valid when the collection is serialised.- Overrides:
setObjectin classSingleFieldMapping- Parameters:
ec- ExecutionContextps- The JDBC Prepared Statement to be populatedexprIndex- The parameter positions in the JDBC statement to populate.value- The value to populate into it
-
getObject
public Object getObject(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Method to retrieve an object from the passed JDBC ResultSet. Only valid when the collection is serialised.- Overrides:
getObjectin classSingleFieldMapping- Parameters:
ec- ExecutionContextresultSet- The ResultSetexprIndex- The parameter position(s) to extract the object from- Returns:
- The collection object
-
getTable
public Table getTable()
Accessor for the datastore class.- Overrides:
getTablein classJavaTypeMapping- Returns:
- The datastore class
-
getNumberOfColumnMappings
public int getNumberOfColumnMappings()
Accessor for the number of columns- Overrides:
getNumberOfColumnMappingsin classJavaTypeMapping- Returns:
- The number of columns
-
getColumnMapping
public ColumnMapping getColumnMapping(int index)
Accessor for a datastore mapping- Overrides:
getColumnMappingin classJavaTypeMapping- Parameters:
index- The id of the mapping- Returns:
- The datastore mapping
-
getColumnMappings
public ColumnMapping[] getColumnMappings()
Accessor for the datastore mappings for this java type- Overrides:
getColumnMappingsin classJavaTypeMapping- Returns:
- The datastore mapping(s)
-
containerIsStoredInSingleColumn
protected boolean containerIsStoredInSingleColumn()
Convenience method to return if the container (collection or map) is stored in the owning table as a column. The container is stored in a single column in the following situations :-- The FieldMetaData has 'serialized="true"'
- The collection has embedded-element="true" but no join table (and so serialised)
- The map has embedded-key/value="true" but no join table (and so serialised)
- The array has embedded-element="true" but no join table (and so serialised)
- The array has no join table and non-PC elements (and so serialised)
- Returns:
- Whether it is stored in a single column in the main table.
-
includeInFetchStatement
public boolean includeInFetchStatement()
This mapping is included in the select statement.- Overrides:
includeInFetchStatementin classJavaTypeMapping- Returns:
- Whether to include in select statement
-
includeInUpdateStatement
public boolean includeInUpdateStatement()
This mapping is included in the update statement.- Overrides:
includeInUpdateStatementin classJavaTypeMapping- Returns:
- Whether to include in update statement
-
includeInInsertStatement
public boolean includeInInsertStatement()
This mapping is included in the insert statement.- Overrides:
includeInInsertStatementin classJavaTypeMapping- Returns:
- Whether to include in insert statement
-
replaceFieldWithWrapper
protected org.datanucleus.store.types.SCO replaceFieldWithWrapper(org.datanucleus.state.DNStateManager sm, Object value)Method to replace the field that this mapping represents with a SCO wrapper. The wrapper will be suitable for the passed instantiated type and if it is null will be for the declared type of the field.- Parameters:
sm- StateManager for the owning objectvalue- The value to create the wrapper with- Returns:
- The SCO wrapper object that the field was replaced with
-
postFetch
public void postFetch(org.datanucleus.state.DNStateManager sm)
Method to be called after any fetch of the owner class element.- Parameters:
sm- StateManager of the owner
-
-