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 classDiscriminator using a Long delegate.static final classDiscriminator using a String delegate. -
Field Summary
FieldsFields inherited from class SingleFieldMapping
EXTENSION_CHECK_CONSTRAINT_VALUESFields inherited from class 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 TypeMethodDescriptionvoidaddColumnMapping(ColumnMapping colMapping) Mutator to add a column mappingstatic DiscriminatorMappingcreateDiscriminatorMapping(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 itselfintAccessor for the number of columns.Accessor for the object in this columnvoidsetObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value) Mutator for the object in this columnMethods inherited from class SingleFieldMapping
getBoolean, getByte, getChar, getDefaultLength, getDouble, getFloat, getInt, getJavaTypeForColumnMapping, getLong, getShort, getString, getValidValues, initialize, prepareColumnMapping, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setStringMethods inherited from class 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:
getJavaTypein 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:
setObjectin classSingleFieldMapping- Parameters:
ec- ExecutionContextps- The statementexprIndex- The indexesvalue- The value to set it to
-
getObject
Accessor for the object in this column- Overrides:
getObjectin 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:
getNumberOfColumnMappingsin classJavaTypeMapping- Returns:
- Number of columns
-
getColumnMapping
Accessor for a datastore mapping- Overrides:
getColumnMappingin classJavaTypeMapping- Parameters:
index- Index of the mapping- Returns:
- The datastore mapping.
-
getColumnMappings
Accessor for the datastore mappings for this java type.- Overrides:
getColumnMappingsin classJavaTypeMapping- Returns:
- The datastore mapping(s)
-
addColumnMapping
Mutator to add a column mapping- Overrides:
addColumnMappingin 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
-