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.
    • Constructor Detail

      • 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 Detail

      • 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
      • 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.
      • 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