Class DiscriminatorMapping

Direct Known Subclasses:
DiscriminatorMapping.DiscriminatorLongMapping, DiscriminatorMapping.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 Details

  • Constructor Details

    • DiscriminatorMapping

      public DiscriminatorMapping(Table table, JavaTypeMapping delegate, org.datanucleus.metadata.DiscriminatorMetaData dismd)
      Constructor.
      Parameters:
      table - Datastore table
      delegate - The JavaTypeMapping to delegate storage
      dismd - Metadata for the discriminator
  • Method Details

    • getJavaType

      public 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(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value)
      Mutator for the object in this column
      Overrides:
      setObject in class SingleFieldMapping
      Parameters:
      ec - ExecutionContext
      ps - The statement
      exprIndex - The indexes
      value - The value to set it to
    • getObject

      public Object getObject(org.datanucleus.ExecutionContext ec, ResultSet 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
    • getNumberOfColumnMappings

      public int getNumberOfColumnMappings()
      Accessor for the number of columns.
      Overrides:
      getNumberOfColumnMappings in class JavaTypeMapping
      Returns:
      Number of columns
    • getColumnMapping

      public ColumnMapping getColumnMapping(int index)
      Accessor for a datastore mapping
      Overrides:
      getColumnMapping in class JavaTypeMapping
      Parameters:
      index - Index of the mapping
      Returns:
      The datastore mapping.
    • getColumnMappings

      public ColumnMapping[] getColumnMappings()
      Accessor for the datastore mappings for this java type.
      Overrides:
      getColumnMappings in class JavaTypeMapping
      Returns:
      The datastore mapping(s)
    • addColumnMapping

      public void addColumnMapping(ColumnMapping colMapping)
      Mutator to add a column mapping
      Overrides:
      addColumnMapping in class JavaTypeMapping
      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 table
      dismd - The discriminator metadata
      Returns:
      Discriminator mapping