Class SFieldBigDecimal

  • All Implemented Interfaces:
    java.io.Serializable

    public class SFieldBigDecimal
    extends SFieldScalar
    Represents BigDecimal field meta data. Default SQL type is NUMERIC(precission, scale), which is roughly sql-92.

    What is the best way to represent money ammounts exactly? Scaled longs are no good for direct end user queries on the database. Doubles tend to loose precission due to Java truncating instead of rounding -- things will not balance. And BigDecimals are inefficient and a real pain to use. Your choice.

    See Also:
    Serialized Form
    • Constructor Detail

      • SFieldBigDecimal

        public SFieldBigDecimal​(SRecordMeta meta,
                                java.lang.String columnName,
                                int precission,
                                int scale,
                                SFieldFlags... pvals)
        Note that precission and scale parameters only affect how the tables are created. The scale that is actually returned is up to JDBC. And then you are responsible for dealing with rounding issues.
    • Method Detail

      • getPrecision

        public int getPrecision()
      • getScale

        public int getScale()
      • queryFieldValue

        public java.lang.Object queryFieldValue​(java.sql.ResultSet rs,
                                                int sqlIndex)
                                         throws java.lang.Exception
        Description copied from class: SFieldMeta
        Issues a JDBC get*() on the result set for the field and converts the database type to the appropriate internal type, eg, Double for a double field. The first column has sqlIndex==1.
        Specified by:
        queryFieldValue in class SFieldMeta
        Throws:
        java.lang.Exception
      • convertToDataSetFieldType

        protected java.lang.Object convertToDataSetFieldType​(java.lang.Object raw)
                                                      throws java.lang.Exception
        Description copied from class: SFieldMeta
        Converts the parameter from the raw type parameter to the correct internal Object type that is stored in the data set. Returns the object if no conversion necessary. Used by SRecordInstance.setObject etc., Not getObject.
        Specified by:
        convertToDataSetFieldType in class SFieldMeta
        Throws:
        java.lang.Exception
      • defaultSqlDataType

        public java.lang.String defaultSqlDataType()
        This is basically SQL 2, and fairly database independent, we hope. Note that "BIGDECIMAL" for Oracle means a text field that can contain over 2K characters!
        Specified by:
        defaultSqlDataType in class SFieldScalar
      • isFKeyCompatible

        public boolean isFKeyCompatible​(SFieldScalar field)
      • javaSqlType

        public int javaSqlType()
        Specified by:
        javaSqlType in class SFieldScalar
        Returns:
        int constant from java.sql.Types, used for setting sql datatype with null values