Class DiscriminatorMapping
java.lang.Object
org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
org.datanucleus.store.rdbms.mapping.java.DiscriminatorMapping
- Direct Known Subclasses:
DiscriminatorMapping.DiscriminatorLongMapping
,DiscriminatorMapping.DiscriminatorStringMapping
Mapping for a discriminator column in a table used in inheritance.
The discriminator column is, by default, a String type, typically VARCHAR.
It can however be "long" based if the user specifies INTEGER, BIGINT, or NUMERIC as the jdbc-type.
In the latter case we make the necessary conversions between value types in this mapping class.
This class is for internal use only. It should not be used in user mappings nor extended.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Discriminator using a Long delegate.static final class
Discriminator using a String delegate. -
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionDiscriminatorMapping
(Table table, JavaTypeMapping delegate, org.datanucleus.metadata.DiscriminatorMetaData dismd) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addColumnMapping
(ColumnMapping colMapping) Mutator to add a column mappingstatic DiscriminatorMapping
createDiscriminatorMapping
(Table table, org.datanucleus.metadata.DiscriminatorMetaData dismd) Convenience method to create a discriminator mapping in the specified table, using the provided discriminator metadata.getColumnMapping
(int index) Accessor for a datastore mappingAccessor for the datastore mappings for this java type.Accessor for the type represented here, returning the class itselfint
Accessor for the number of columns.Accessor for the object in this columnvoid
setObject
(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value) Mutator for the object in this columnMethods inherited from class org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
getBoolean, getByte, getChar, getDefaultLength, getDouble, getFloat, getInt, getJavaTypeForColumnMapping, getLong, getShort, getString, getValidValues, initialize, prepareColumnMapping, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setString
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
equals, failureMessage, getAbsoluteFieldNumber, getColumnMetaDataForMember, getMemberMetaData, getObject, getReferenceMapping, getRoleForMember, getStoreManager, getTable, getType, getValueForColumnMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, initialize, isNullable, isSerialised, performSetPostProcessing, representableAsStringLiteralInStatement, requiresSetPostProcessing, setAbsFieldNumber, setMemberMetaData, setObject, setReferenceMapping, setRoleForMember, setTable
-
Field Details
-
delegate
-
-
Constructor Details
-
DiscriminatorMapping
public DiscriminatorMapping(Table table, JavaTypeMapping delegate, org.datanucleus.metadata.DiscriminatorMetaData dismd) Constructor.- Parameters:
table
- Datastore tabledelegate
- The JavaTypeMapping to delegate storagedismd
- Metadata for the discriminator
-
-
Method Details
-
getJavaType
Accessor for the type represented here, returning the class itself- Specified by:
getJavaType
in classJavaTypeMapping
- Returns:
- This class.
-
setObject
public void setObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value) Mutator for the object in this column- Overrides:
setObject
in classSingleFieldMapping
- Parameters:
ec
- ExecutionContextps
- The statementexprIndex
- The indexesvalue
- The value to set it to
-
getObject
Accessor for the object in this column- Overrides:
getObject
in classSingleFieldMapping
- Parameters:
ec
- ExecutionContextresultSet
- The ResultSet to get the value fromexprIndex
- The indexes- Returns:
- The object
-
getNumberOfColumnMappings
public int getNumberOfColumnMappings()Accessor for the number of columns.- Overrides:
getNumberOfColumnMappings
in classJavaTypeMapping
- Returns:
- Number of columns
-
getColumnMapping
Accessor for a datastore mapping- Overrides:
getColumnMapping
in classJavaTypeMapping
- Parameters:
index
- Index of the mapping- Returns:
- The datastore mapping.
-
getColumnMappings
Accessor for the datastore mappings for this java type.- Overrides:
getColumnMappings
in classJavaTypeMapping
- Returns:
- The datastore mapping(s)
-
addColumnMapping
Mutator to add a column mapping- Overrides:
addColumnMapping
in classJavaTypeMapping
- Parameters:
colMapping
- Column mapping
-
createDiscriminatorMapping
public static DiscriminatorMapping createDiscriminatorMapping(Table table, org.datanucleus.metadata.DiscriminatorMetaData dismd) Convenience method to create a discriminator mapping in the specified table, using the provided discriminator metadata.- Parameters:
table
- The tabledismd
- The discriminator metadata- Returns:
- Discriminator mapping
-