Class MultiPersistableMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
-
- org.datanucleus.store.rdbms.mapping.java.MultiMapping
-
- org.datanucleus.store.rdbms.mapping.java.MultiPersistableMapping
-
- Direct Known Subclasses:
ReferenceMapping
,SubclassPCMapping
public abstract class MultiPersistableMapping extends MultiMapping
Extension of MultiMapping where the actual mapping represents multiple possible persistable types such as with an interface/reference field. For example, with an interface mapping we have say 3 known implementations of the interface, so this mapping represents 3 FKs. A maximum of one will be set and the others null.
-
-
Field Summary
-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.MultiMapping
javaTypeMappings, numberOfColumnMappings
-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type
-
-
Constructor Summary
Constructors Constructor Description MultiPersistableMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getMappingNumberForValue(org.datanucleus.ExecutionContext ec, java.lang.Object value)
Convenience accessor for the number of the java type mapping where the passed value would be stored.java.lang.Object
getObject(org.datanucleus.ExecutionContext ec, java.sql.ResultSet rs, int[] pos)
Method to retrieve an object of this type from the ResultSet.void
setObject(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] pos, java.lang.Object value)
Method to set the parameters in the PreparedStatement with the fields of this object.void
setObject(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] pos, java.lang.Object value, org.datanucleus.state.DNStateManager ownerSM, int ownerFieldNumber)
Sets the specified positions in the PreparedStatement associated with this field, and value.-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.MultiMapping
addJavaTypeMapping, getColumnMapping, getColumnMappings, getJavaTypeMapping, getNumberOfColumnMappings
-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
addColumnMapping, equals, failureMessage, getAbsoluteFieldNumber, getBoolean, getByte, getChar, getColumnMetaDataForMember, getDouble, getFloat, getInt, getJavaType, getJavaTypeForColumnMapping, getLong, getMemberMetaData, getObject, getReferenceMapping, getRoleForMember, getShort, getStoreManager, getString, getTable, getType, getValueForColumnMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, initialize, initialize, isNullable, isSerialised, performSetPostProcessing, representableAsStringLiteralInStatement, requiresSetPostProcessing, setAbsFieldNumber, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setMemberMetaData, setReferenceMapping, setRoleForMember, setShort, setString, setTable
-
-
-
-
Method Detail
-
getMappingNumberForValue
protected int getMappingNumberForValue(org.datanucleus.ExecutionContext ec, java.lang.Object value)
Convenience accessor for the number of the java type mapping where the passed value would be stored. If no suitable mapping is found will return -1. If is a persistent interface then will return -2 meaning persist against *any* mapping- Parameters:
ec
- ExecutionContextvalue
- The value- Returns:
- The index of javaTypeMappings to use (if any), or -1 (none), or -2 (any)
-
setObject
public void setObject(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] pos, java.lang.Object value)
Method to set the parameters in the PreparedStatement with the fields of this object.- Overrides:
setObject
in classJavaTypeMapping
- Parameters:
ec
- execution contextps
- The PreparedStatementpos
- The parameter positionsvalue
- The object to populate the statement with- Throws:
org.datanucleus.exceptions.NotYetFlushedException
- Thrown if the object is not yet flushed to the datastore
-
setObject
public void setObject(org.datanucleus.ExecutionContext ec, java.sql.PreparedStatement ps, int[] pos, java.lang.Object value, org.datanucleus.state.DNStateManager ownerSM, int ownerFieldNumber)
Sets the specified positions in the PreparedStatement associated with this field, and value. If the number of positions in "pos" is not the same as the number of datastore mappings then it is assumed that we should only set the positions for the real implementation FK; this happens where we have a statement like "... WHERE IMPL1_ID_OID = ? AND IMPL2_ID_OID IS NULL" so we need to filter on the other implementations being null and only want to input parameter(s) for the real implementation of "value".- Overrides:
setObject
in classJavaTypeMapping
- Parameters:
ec
- execution contextps
- a datastore object that executes statements in the databasevalue
- the value stored in this fieldownerSM
- the owner StateManagerownerFieldNumber
- the owner absolute field numberpos
- The position(s) of the PreparedStatement to populate
-
getObject
public java.lang.Object getObject(org.datanucleus.ExecutionContext ec, java.sql.ResultSet rs, int[] pos)
Method to retrieve an object of this type from the ResultSet.- Overrides:
getObject
in classJavaTypeMapping
- Parameters:
ec
- execution contextrs
- The ResultSetpos
- The parameter positions- Returns:
- The object
-
-