Class TimestampColumnMapping

java.lang.Object
org.datanucleus.store.rdbms.mapping.column.AbstractColumnMapping
org.datanucleus.store.rdbms.mapping.column.TimestampColumnMapping
All Implemented Interfaces:
ColumnMapping

public class TimestampColumnMapping extends AbstractColumnMapping
Mapping of a TIMESTAMP column.
  • Constructor Details

  • Method Details

    • initialize

      private void initialize()
    • getJDBCType

      public int getJDBCType()
      Description copied from class: AbstractColumnMapping
      Method to return the java.sql.Types type that this relates to.
      Specified by:
      getJDBCType in class AbstractColumnMapping
      Returns:
      The JDBC "type"
    • setObject

      public void setObject(PreparedStatement ps, int param, Object value)
      Method to set an object in a PreparedStatement for sending to the datastore.
      Specified by:
      setObject in interface ColumnMapping
      Overrides:
      setObject in class AbstractColumnMapping
      Parameters:
      ps - The PreparedStatement
      param - The parameter position (in the statement)
      value - The value to set
    • getTimestamp

      protected Timestamp getTimestamp(ResultSet rs, int param)
      Method to access a Timestamp from the ResultSet.
      Parameters:
      rs - The ResultSet
      param - The parameter position in the ResultSet row.
      Returns:
      The Timestamp object
    • getObject

      public Object getObject(ResultSet rs, int param)
      Method to access an Object from the ResultSet.
      Specified by:
      getObject in interface ColumnMapping
      Overrides:
      getObject in class AbstractColumnMapping
      Parameters:
      rs - The ResultSet
      param - The parameter position in the ResultSet row.
      Returns:
      The Object
    • stringToTimestamp

      private static Timestamp stringToTimestamp(String s, Calendar cal)
      Converts a string in JDBC timestamp escape format to a Timestamp object. To be precise, we prefer to find a JDBC escape type sequence in the format "yyyy-mm-dd hh:mm:ss.fffffffff", but this does not accept other separators of fields, so as long as the numbers are in the order year, month, day, hour, minute, second then we accept it.
      Parameters:
      s - Timestamp string
      cal - The Calendar to use for conversion
      Returns:
      Corresponding java.sql.Timestamp value.
      Throws:
      IllegalArgumentException - Thrown if the format of the String is invalid
    • convertStringToIntArray

      private static int[] convertStringToIntArray(String str)
      Convenience method to convert a String containing numbers (separated by assorted characters) into an int array. The separators can be ' ' '-' ':' '.' ',' etc.
      Parameters:
      str - The String
      Returns:
      The int array