Class StatementMappingIndex


  • public class StatementMappingIndex
    extends Object
    Representation of a mapping in a statement (such as JDBC), and its mapping to the associated column(s) or parameters that the mapping relates to. The mapping may be for a field of a class (whether it is a real field or a surrogate), or for a parameter.
    • Provides index positions of the column(s) of this field in the result clause of the statement
    • Provides parameter position(s) if any of the column(s) are statement parameters, for input
    For example, fields of a class in the result clause of a statement.
     CLASS                 FIELDNUM     MAPPING            TABLE                COLUMN POSITIONS
     -----------------     --------     --------------     ----------------     ----------------
     class A                                               TABLE_A              
     {
        short fieldA;      1            ShortMapping       COL_FIELDA           1
        String fieldB;     2            StringMapping      COL_FIELDB_PART1     2
                                                           COL_FIELDB_PART2     3
        ...
     }
     
    • Constructor Detail

      • StatementMappingIndex

        public StatementMappingIndex​(JavaTypeMapping mapping)
    • Method Detail

      • getColumnAlias

        public String getColumnAlias()
        Accessor for the column name alias (if any). Only applies to the first column for this field.
        Returns:
        The column alias.
      • setColumnAlias

        public void setColumnAlias​(String alias)
        Mutator for the column name (alias). Overrides the name of the field that the mapping refers to.
        Parameters:
        alias - The name of the column (alias).
      • getColumnPositions

        public int[] getColumnPositions()
        Accessor for the column position(s).
        Returns:
        The column position(s) in the result clause of the statement.
      • setColumnPositions

        public void setColumnPositions​(int[] pos)
        Mutator for the column positions in the result clause of a statement.
        Parameters:
        pos - The column position(s)
      • addParameterOccurrence

        public void addParameterOccurrence​(int[] positions)
        Method to register statement position(s) that this mapping is used as a parameter. The number of positions must be the same as the mapping number of columns.
        Parameters:
        positions - The parameter positions in the statement.
      • removeParameterOccurrence

        public void removeParameterOccurrence​(int[] positions)
        Method to deregister statement positions that this mapping is used as a parameter.
        Parameters:
        positions - The param positions to deregister
      • getNumberOfParameterOccurrences

        public int getNumberOfParameterOccurrences()
        Accessor for the number of times this mapping is used as a parameter.
        Returns:
        Number of times used as a parameter
      • getParameterPositionsForOccurrence

        public int[] getParameterPositionsForOccurrence​(int num)
        Accessor for the parameter positions for this occurrence of use of the mapping as a parameter.
        Parameters:
        num - The occurrence of using this mapping as a parameter.
        Returns:
        The parameter positions
      • toString

        public String toString()
        Method to return a string version of this object.
        Overrides:
        toString in class Object
        Returns:
        String version