001package com.avaje.ebean.config.dbplatform;
002
003import java.sql.Types;
004
005import javax.sql.DataSource;
006
007import com.avaje.ebean.BackgroundExecutor;
008import com.avaje.ebean.dbmigration.ddlgeneration.platform.DB2Ddl;
009
010/**
011 * DB2 specific platform.
012 */
013public class DB2Platform extends DatabasePlatform {
014
015  public DB2Platform() {
016    super();
017    this.name = "db2";
018    this.maxTableNameLength = 18;
019    this.maxConstraintNameLength = 18;
020    this.sqlLimiter = new Db2SqlLimiter();
021    this.platformDdl = new DB2Ddl(this);
022
023    this.dbIdentity.setSupportsGetGeneratedKeys(true);
024    this.dbIdentity.setSupportsSequence(true);
025
026    booleanDbType = Types.BOOLEAN;
027    dbTypeMap.put(Types.REAL, new DbType("real"));
028    dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
029    dbTypeMap.put(Types.DECIMAL, new DbType("decimal", 15));
030  }
031
032  /**
033   * Return a DB2 specific sequence IdGenerator that supports batch fetching
034   * sequence values.
035   */
036  @Override
037  public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be,
038                                                       DataSource ds, String seqName, int batchSize) {
039
040    return new DB2SequenceIdGenerator(be, ds, seqName, batchSize);
041  }
042
043}