Class H2Support

All Implemented Interfaces:
DatabaseSupport

public class H2Support extends AbstractDatabaseSupport
H2-specific DatabaseSupport.

H2 is an embedded, in-process database widely used as a JVM test fixture. It is largely standard-SQL, so most columns map through the cross-database defaults in AbstractDatabaseSupport (including TIMESTAMP WITH TIME ZONE, CLOB, and BLOB). This class customizes the few types where H2 diverges:

  • TINYINT — H2's is a signed 8-bit type (-128..127), whereas the cross-database default targets MySQL's unsigned 0..255 range and would overflow.
  • UUID — the H2 driver reports it as JDBC JDBCType.BINARY (16 bytes) with type name "UUID"; a real UUID is generated rather than 16 random bytes.
  • JSON — surfaces as JDBC JDBCType.OTHER with type name "JSON"; H2 parses the value, so valid JSON is generated.

H2's first-class ARRAY and INTERVAL types and its non-standard ENUM and GEOMETRY types are not yet supported and cause AbstractDatabaseSupport.getDataGenerator(Column, RandomGenerator) to throw.

Since:
2.18.0
See Also:
  • Constructor Details

    • H2Support

      public H2Support()
      Creates the H2 support with its default configuration.
  • Method Details

    • configure

      protected void configure(Map<JDBCType, GeneratorFactory> registry)
      Description copied from class: AbstractDatabaseSupport
      Hook for subclasses to add or replace generator factories for specific JDBC types. The supplied registry already holds the cross-database defaults; subclasses with no customizations need not override this method. Implementations must not retain a reference to the map beyond the call.
      Overrides:
      configure in class AbstractDatabaseSupport
      Parameters:
      registry - the mutable registry to customize, keyed by JDBCType