# Class H2Adapter

java.lang.Object
org.apache.cayenne.dba.JdbcAdapter
org.apache.cayenne.dba.h2.H2Adapter

All Implemented Interfaces:
  `DbAdapter`

public class H2Adapter extends JdbcAdapter
DbAdapter implementation for H2 RDBMS.

Since:
  3.0

- ## Field Summary

  ### Fields inherited from class JdbcAdapter

  `caseInsensitiveCollations, defaultCharColumnLength, ejbqlTranslator, extendedTypes, logger, nativeColumnTypes, quotingStrategy, supportsBatchUpdates, supportsGeneratedKeys, supportsUniqueConstraints`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `H2Adapter(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ValueObjectTypeRegistry valueObjectTypeRegistry)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DbAttribute`
  `buildAttribute(String name, String typeName, int type, int maxLength, int scale, boolean allowNulls)`
  Creates and returns a DbAttribute based on supplied parameters (usually obtained from database metadata).
  `protected void`
  `configureExtendedTypes(ExtendedTypeMap map)`
  Installs appropriate ExtendedTypes as converters for passing values between JDBC and Java layers.
  `protected EJBQLTranslator`
  `createEJBQLTranslator()`
  Creates and returns an `EJBQLTranslator` used to generate visitors for EJBQL to SQL translations.
  `protected NativeColumnType[]`
  `createNativeTypes()`
  Returns the database-native types supported by this adapter.
  `PkGenerator`
  `createPkGenerator()`
  Returns a `H2PkGenerator`.
  `void`
  `createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column)`
  Appends SQL for column creation to CREATE TABLE buffer.
  `SQLAction`
  `getAction(Query query, DataNode node)`
  Uses JdbcActionBuilder to create the right action.
  `SQLTreeProcessor`
  `getSqlTreeProcessor()`

  ### Methods inherited from class JdbcAdapter

  `bind, bindParameter, bindParameter, createFkConstraint, createQuotingStrategy, createTable, createTableAppendPKClause, createUniqueConstraint, defaultCharColumnLength, dropTableStatements, externalTypesForJdbcType, getBatchTerminator, getEjbqlTranslator, getExtendedTypes, getProcedureTranslator, getQuotingStrategy, getQuotingStrategy, getSelectTranslator, getSQLLogger, getSystemCatalogs, getSystemSchemas, getType, initExtendedTypes, nativeColumnTypes, setEjbqlTranslator, setEjbqlTranslatorFactory, setSupportsBatchUpdates, setSupportsGeneratedKeys, setSupportsUniqueConstraints, sizeAndPrecision, sizeAndScale, supportsBatchUpdates, supportsCatalogsOnReverseEngineering, supportsGeneratedKeys, supportsUniqueConstraints, tableTypeForTable, tableTypeForView, typeSupportsLength, typeSupportsScale, unwrap`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface DbAdapter

  `getEjbqlTranslatorFactory, preferredBindingType, preferredNativeColumnType, supportsGeneratedKeysForBatchInserts`

- ## Constructor Details

  - ### H2Adapter

    public H2Adapter(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ValueObjectTypeRegistry valueObjectTypeRegistry)

- ## Method Details

  - ### createNativeTypes

    protected NativeColumnType[] createNativeTypes()
    Description copied from class: `JdbcAdapter`
    Returns the database-native types supported by this adapter.
    Overrides:
      `createNativeTypes` in class `JdbcAdapter`

  - ### createTableAppendColumn

    public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column)
    Description copied from class: `JdbcAdapter`
    Appends SQL for column creation to CREATE TABLE buffer.
    Specified by:
      `createTableAppendColumn` in interface `DbAdapter`
    Overrides:
      `createTableAppendColumn` in class `JdbcAdapter`
    Parameters:
      `sqlBuffer` - the `StringBuffer` to append the column type to
      `column` - the `DbAttribute` defining the column to append type for

  - ### createPkGenerator

    public PkGenerator createPkGenerator()
    Returns a `H2PkGenerator`.
    Specified by:
      `createPkGenerator` in interface `DbAdapter`
    Overrides:
      `createPkGenerator` in class `JdbcAdapter`

  - ### getSqlTreeProcessor

    public SQLTreeProcessor getSqlTreeProcessor()
    Specified by:
      `getSqlTreeProcessor` in interface `DbAdapter`
    Overrides:
      `getSqlTreeProcessor` in class `JdbcAdapter`
    Returns:
      `SQLTreeProcessor` that can adjust SQL tree to specific database flavour
    Since:
      4.2

  - ### createEJBQLTranslator

    protected EJBQLTranslator createEJBQLTranslator()
    Description copied from class: `JdbcAdapter`
    Creates and returns an `EJBQLTranslator` used to generate visitors for EJBQL to SQL translations. This method should be overriden by subclasses that need to customize EJBQL generation.
    Overrides:
      `createEJBQLTranslator` in class `JdbcAdapter`
    Returns:
      translator factory for EJBQL queries
    Since:
      5.0

  - ### getAction

    public SQLAction getAction(Query query, DataNode node)
    Description copied from class: `JdbcAdapter`
    Uses JdbcActionBuilder to create the right action.
    Specified by:
      `getAction` in interface `DbAdapter`
    Overrides:
      `getAction` in class `JdbcAdapter`

  - ### configureExtendedTypes

    protected void configureExtendedTypes(ExtendedTypeMap map)
    Installs appropriate ExtendedTypes as converters for passing values between JDBC and Java layers.
    Overrides:
      `configureExtendedTypes` in class `JdbcAdapter`
    Since:
      4.1.2

  - ### buildAttribute

    public DbAttribute buildAttribute(String name, String typeName, int type, int maxLength, int scale, boolean allowNulls)
    Description copied from interface: `DbAdapter`
    Creates and returns a DbAttribute based on supplied parameters (usually obtained from database metadata).
    Specified by:
      `buildAttribute` in interface `DbAdapter`
    Overrides:
      `buildAttribute` in class `JdbcAdapter`
    Parameters:
      `name` - database column name
      `typeName` - database specific type name, may be used as a hint to determine the right JDBC type.
      `type` - JDBC column type
      `maxLength` - database column size (ignored if less than zero)
      `scale` - database column scale, i.e. the number of decimal digits (ignored if less than zero)
      `allowNulls` - database column nullable parameter