Class BigDecimalGenerator

All Implemented Interfaces:
DataGenerator<BigDecimal>

public class BigDecimalGenerator extends AbstractDataGenerator<BigDecimal>
Generates BigDecimal values sized to a column's declared precision and scale using the seeded random source, so a given seed yields a reproducible sequence. When a precision is configured the value has up to maxPrecision total significant digits with maxDigits of them to the right of the decimal point; both bounds are capped at 25 to keep test values manageable (some databases report enormous precision). When no precision is configured the value falls back to one produced by a DoubleGenerator. For a value constrained to an explicit numeric range and fixed scale see ScaledBigDecimalGenerator; for a fixed value see StaticBigDecimalGenerator.
  • Method Details

    • generate

      public BigDecimal generate()
      Description copied from interface: DataGenerator
      Generates a random value of type T.
      Returns:
      a generated value, may be null if the generator supports nullable columns
    • set

      public void set(Connection connection, PreparedStatement statement, int parameterIndex, BigDecimal value) throws SQLException
      Description copied from interface: DataGenerator
      Sets a specific value on a PreparedStatement parameter.
      Specified by:
      set in interface DataGenerator<BigDecimal>
      Overrides:
      set in class AbstractDataGenerator<BigDecimal>
      Parameters:
      connection - the database connection
      statement - the prepared statement to set the parameter on
      parameterIndex - the 1-based parameter index
      value - the value to set
      Throws:
      SQLException - if the database operation fails
    • get

      public BigDecimal get(ResultSet resultSet, int columnIndex) throws SQLException
      Description copied from interface: DataGenerator
      Retrieves a value from a ResultSet column.
      Parameters:
      resultSet - the result set to read from
      columnIndex - the 1-based column index
      Returns:
      the value from the result set, properly cast to type T
      Throws:
      SQLException - if the database operation fails