org.datanucleus.store.mapped.mapping
Class DiscriminatorMapping

java.lang.Object
  extended by org.datanucleus.store.mapped.mapping.JavaTypeMapping
      extended by org.datanucleus.store.mapped.mapping.SingleFieldMapping
          extended by org.datanucleus.store.mapped.mapping.DiscriminatorMapping
Direct Known Subclasses:
DiscriminatorLongMapping, DiscriminatorStringMapping

public class DiscriminatorMapping
extends SingleFieldMapping

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.


Field Summary
 
Fields inherited from class org.datanucleus.store.mapped.mapping.JavaTypeMapping
datastoreContainer, datastoreMappings, LOCALISER, mmd, referenceMapping, roleForMember, storeMgr, type
 
Constructor Summary
DiscriminatorMapping(DatastoreAdapter dba, DatastoreContainerObject datastoreContainer, JavaTypeMapping delegate)
          Constructor.
 
Method Summary
 void addDatastoreMapping(DatastoreMapping datastoreMapping)
          Mutator to add a datastore mapping
 DatastoreMapping getDatastoreMapping(int index)
          Accessor for a datastore mapping
 DatastoreMapping[] getDatastoreMappings()
          Accessor for the datastore mappings for this java type.
 java.lang.Class getJavaType()
          Accessor for the type represented here, returning the class itself
 int getNumberOfDatastoreMappings()
          Accessor for the number of datastore fields.
 java.lang.Object getObject(ExecutionContext ec, java.lang.Object resultSet, int[] exprIndex)
          Accessor for the object in this column
 void setObject(ExecutionContext ec, java.lang.Object preparedStatement, int[] exprIndex, java.lang.Object value)
          Mutator for the object in this column
 
Methods inherited from class org.datanucleus.store.mapped.mapping.SingleFieldMapping
equals, getBoolean, getByte, getChar, getDefaultLength, getDouble, getFloat, getInt, getJavaTypeForDatastoreMapping, getLong, getShort, getString, getValidValues, initialize, prepareDatastoreMapping, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setString
 
Methods inherited from class org.datanucleus.store.mapped.mapping.JavaTypeMapping
failureMessage, getColumnMetaDataForMember, getDatastoreContainer, getMemberMetaData, getObject, getReferenceMapping, getRoleForMember, getType, getValueForDatastoreMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, initialize, isNullable, isSerialised, setDatastoreContainer, setMemberMetaData, setObject, setReferenceMapping, setRoleForMember
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscriminatorMapping

public DiscriminatorMapping(DatastoreAdapter dba,
                            DatastoreContainerObject datastoreContainer,
                            JavaTypeMapping delegate)
Constructor.

Parameters:
dba - Datastore Adapter
datastoreContainer - Datastore table
delegate - The JavaTypeMapping to delegate storage
Method Detail

getJavaType

public java.lang.Class getJavaType()
Accessor for the type represented here, returning the class itself

Specified by:
getJavaType in class JavaTypeMapping
Returns:
This class.

setObject

public void setObject(ExecutionContext ec,
                      java.lang.Object preparedStatement,
                      int[] exprIndex,
                      java.lang.Object value)
Mutator for the object in this column

Overrides:
setObject in class SingleFieldMapping
Parameters:
ec - ExecutionContext
preparedStatement - The statement
exprIndex - The indexes
value - The value to set it to

getObject

public java.lang.Object getObject(ExecutionContext ec,
                                  java.lang.Object resultSet,
                                  int[] exprIndex)
Accessor for the object in this column

Overrides:
getObject in class SingleFieldMapping
Parameters:
ec - ExecutionContext
resultSet - The ResultSet to get the value from
exprIndex - The indexes
Returns:
The object

getNumberOfDatastoreMappings

public int getNumberOfDatastoreMappings()
Accessor for the number of datastore fields.

Overrides:
getNumberOfDatastoreMappings in class JavaTypeMapping
Returns:
Number of datastore fields

getDatastoreMapping

public DatastoreMapping getDatastoreMapping(int index)
Accessor for a datastore mapping

Overrides:
getDatastoreMapping in class JavaTypeMapping
Parameters:
index - Index of the mapping
Returns:
The datastore mapping.

getDatastoreMappings

public DatastoreMapping[] getDatastoreMappings()
Accessor for the datastore mappings for this java type.

Overrides:
getDatastoreMappings in class JavaTypeMapping
Returns:
The datastore mapping(s)

addDatastoreMapping

public void addDatastoreMapping(DatastoreMapping datastoreMapping)
Mutator to add a datastore mapping

Overrides:
addDatastoreMapping in class JavaTypeMapping
Parameters:
datastoreMapping - Datastore mapping


Copyright © 2011. All Rights Reserved.