Class AbstractColumnMapping

    • Field Detail

      • mapping

        protected final JavaTypeMapping mapping
        Mapping of the Java type.
      • storeMgr

        protected final RDBMSStoreManager storeMgr
        Store Manager to use for mapping.
      • column

        protected Column column
        The Column being persisted to.
    • Constructor Detail

      • AbstractColumnMapping

        protected AbstractColumnMapping​(RDBMSStoreManager storeMgr,
                                        JavaTypeMapping mapping)
        Create a new Mapping with the given DatabaseAdapter for the given type.
        Parameters:
        storeMgr - The Store Manager that this Mapping should use.
        mapping - Mapping for the underlying java type. This can be null on an "unmapped column".
    • Method Detail

      • getDatastoreAdapter

        protected DatastoreAdapter getDatastoreAdapter()
        Convenience to access the datastore adapter.
        Returns:
        The adapter in use
      • initTypeInfo

        protected void initTypeInfo()
        Sets the TypeInfo for the columns of the Mapping. Mappings using two or more columns using different TypeInfo(s) should overwrite this method to appropriate set the TypeInfo (SQL type) for all the columns
      • getJDBCType

        public abstract int getJDBCType()
        Method to return the java.sql.Types type that this relates to.
        Returns:
        The JDBC "type"
      • getTypeInfo

        public SQLTypeInfo getTypeInfo()
        Accessor for the (SQL) type info for this datastore type. Finds the SQLTypeInfo using the JDBC Type for this mapping. Override if you want a different method.
        Returns:
        The type info
      • isNullable

        public boolean isNullable()
        Accessor for whether the mapping is nullable.
        Specified by:
        isNullable in interface ColumnMapping
        Returns:
        Whether it is nullable
      • includeInFetchStatement

        public boolean includeInFetchStatement()
        Whether this mapping is included in the fetch statement.
        Returns:
        Whether to include in fetch statement
      • insertValuesOnInsert

        public boolean insertValuesOnInsert()
        Accessor for whether this mapping requires values inserting on an INSERT.
        Specified by:
        insertValuesOnInsert in interface ColumnMapping
        Returns:
        Whether values are to be inserted into this mapping on an INSERT
      • getInsertionInputParameter

        public String getInsertionInputParameter()
        Accessor for the string to put in any retrieval datastore statement for this field. In RDBMS, this is typically a ? to be used in JDBC statements.
        Specified by:
        getInsertionInputParameter in interface ColumnMapping
        Returns:
        The input parameter
      • getUpdateInputParameter

        public String getUpdateInputParameter()
        Accessor for the string to put in any update datastore statements for this field. In RDBMS, this is typically a ? to be used in JDBC statements.
        Specified by:
        getUpdateInputParameter in interface ColumnMapping
        Returns:
        The input parameter.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • useDefaultWhenNull

        protected boolean useDefaultWhenNull()
      • failureMessage

        protected String failureMessage​(String method,
                                        int position,
                                        Exception e)
        Utility to output any error message.
        Parameters:
        method - The method that failed.
        position - The position of the column
        e - The exception
        Returns:
        The localised failure message
      • failureMessage

        protected String failureMessage​(String method,
                                        Object value,
                                        Exception e)
        Utility to output any error message.
        Parameters:
        method - The method that failed.
        value - Value at the position
        e - The exception
        Returns:
        The localised failure message
      • setBoolean

        public void setBoolean​(PreparedStatement ps,
                               int exprIndex,
                               boolean value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setBoolean in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getBoolean

        public boolean getBoolean​(ResultSet resultSet,
                                  int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getBoolean in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setChar

        public void setChar​(PreparedStatement ps,
                            int exprIndex,
                            char value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setChar in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getChar

        public char getChar​(ResultSet resultSet,
                            int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getChar in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setByte

        public void setByte​(PreparedStatement ps,
                            int exprIndex,
                            byte value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setByte in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getByte

        public byte getByte​(ResultSet resultSet,
                            int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getByte in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setShort

        public void setShort​(PreparedStatement ps,
                             int exprIndex,
                             short value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setShort in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getShort

        public short getShort​(ResultSet resultSet,
                              int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getShort in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setInt

        public void setInt​(PreparedStatement ps,
                           int exprIndex,
                           int value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setInt in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getInt

        public int getInt​(ResultSet resultSet,
                          int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getInt in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setLong

        public void setLong​(PreparedStatement ps,
                            int exprIndex,
                            long value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setLong in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getLong

        public long getLong​(ResultSet resultSet,
                            int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getLong in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setFloat

        public void setFloat​(PreparedStatement ps,
                             int exprIndex,
                             float value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setFloat in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getFloat

        public float getFloat​(ResultSet resultSet,
                              int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getFloat in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setDouble

        public void setDouble​(PreparedStatement ps,
                              int exprIndex,
                              double value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setDouble in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getDouble

        public double getDouble​(ResultSet resultSet,
                                int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getDouble in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setString

        public void setString​(PreparedStatement ps,
                              int exprIndex,
                              String value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setString in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getString

        public String getString​(ResultSet resultSet,
                                int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getString in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • setObject

        public void setObject​(PreparedStatement ps,
                              int exprIndex,
                              Object value)
        Description copied from interface: ColumnMapping
        Sets a value into ps at position specified by paramIndex.
        Specified by:
        setObject in interface ColumnMapping
        Parameters:
        ps - PreparedStatement
        exprIndex - the position of the value in the statement
        value - the value
      • getObject

        public Object getObject​(ResultSet resultSet,
                                int exprIndex)
        Description copied from interface: ColumnMapping
        Obtains a value from resultSet at position specified by exprIndex.
        Specified by:
        getObject in interface ColumnMapping
        Parameters:
        resultSet - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • isDecimalBased

        public boolean isDecimalBased()
        Accessor for whether the mapping is decimal-based.
        Specified by:
        isDecimalBased in interface ColumnMapping
        Returns:
        Whether the mapping is decimal based
      • isIntegerBased

        public boolean isIntegerBased()
        Accessor for whether the mapping is integer-based.
        Specified by:
        isIntegerBased in interface ColumnMapping
        Returns:
        Whether the mapping is integer based
      • isStringBased

        public boolean isStringBased()
        Accessor for whether the mapping is string-based.
        Specified by:
        isStringBased in interface ColumnMapping
        Returns:
        Whether the mapping is string based
      • isBitBased

        public boolean isBitBased()
        Accessor for whether the mapping is bit-based.
        Specified by:
        isBitBased in interface ColumnMapping
        Returns:
        Whether the mapping is bit based
      • isBooleanBased

        public boolean isBooleanBased()
        Accessor for whether the mapping is boolean-based.
        Specified by:
        isBooleanBased in interface ColumnMapping
        Returns:
        Whether the mapping is boolean based
      • failureMessage

        protected String failureMessage​(String method)
        Utility to output any error message.
        Parameters:
        method - The method that failed.
        Returns:
        The localised failure message