/** * Create a copy of the type with a new default length. */ public DbPlatformType withLength(int defaultLength) { return new DbPlatformType(name, defaultLength); } }
private DbPlatformType parse(String columnDefinition) { return DbPlatformType.parse(columnDefinition); }
/** * Return the DB column type definition. */ public String renderDbType(DbPlatformType dbType, boolean strict) { if (dbColumnDefn != null) { return dbColumnDefn; } return dbType.renderType(dbLength, dbScale, strict); }
put(DbType.LONGVARCHAR); put(DbType.REAL, new DbPlatformType("float")); put(DbType.VARCHAR, new DbPlatformType("varchar")); put(DbType.DECIMAL, new DbPlatformType("decimal")); put(DbType.VARBINARY, new DbPlatformType("varbinary")); put(DbType.BINARY, new DbPlatformType("binary")); put(DbType.CHAR, new DbPlatformType("char")); put(DbType.HSTORE, new DbPlatformType("hstore", false)); put(DbType.JSON, new DbPlatformType("json", false)); put(DbType.JSONB, new DbPlatformType("jsonb", false)); put(DbType.JSONCLOB, new DbPlatformType("jsonclob")); put(DbType.JSONBLOB, new DbPlatformType("jsonblob")); put(DbType.JSONVARCHAR, new DbPlatformType("jsonvarchar", 1000)); put(DbType.UUID, UUID_NATIVE); put(DbType.VARCHAR, new DbPlatformType("varchar", 255)); put(DbType.DECIMAL, new DbPlatformType("decimal", 38)); put(DbType.VARBINARY, new DbPlatformType("varbinary", 255)); put(DbType.BINARY, new DbPlatformType("binary", 255)); put(DbType.CHAR, new DbPlatformType("char", 1)); put(DbType.JSONVARCHAR, JSON_VARCHAR_PLACEHOLDER); put(DbType.UUID, get(DbType.VARCHAR).withLength(40));
/** * Map the UUID appropriately based on native DB support and ServerConfig.DbUuid. */ public void config(boolean nativeUuidType, ServerConfig.DbUuid dbUuid) { if (nativeUuidType && dbUuid.useNativeType()) { put(DbType.UUID, UUID_NATIVE); } else if (dbUuid.useBinary()) { put(DbType.UUID, get(DbType.BINARY).withLength(16)); } else { put(DbType.UUID, get(DbType.VARCHAR).withLength(40)); } } }
private DbPlatformType geoType(String type, int srid) { return new DbPlatformType("geometry(" + type + "," + srid + ")"); }
/** * Return the type for a specific property that incorporates the name, length, * precision and scale. * <p> * The deployLength and deployScale are for the property we are rendering the * DB type for. * </p> * * @param deployLength the length or precision defined by deployment on a specific * property. * @param deployScale the scale defined by deployment on a specific property. */ public String renderType(int deployLength, int deployScale) { return renderType(deployLength, deployScale, true); }
/** * Create a platform type without scale or precision. */ public DbPlatformType createPlatformType() { return new DbPlatformType(name().toLowerCase()); } }
/** * Convert a simple type with not scale or precision. */ protected String convertNoScale(String columnDefinition) { try { DbPlatformType dbType = platformTypes.lookup(columnDefinition, false); return dbType.renderType(0, 0); } catch (IllegalArgumentException e) { // assume already platform specific, leave as is return columnDefinition; } }
return new DbPlatformType(columnDefinition, false); return new DbPlatformType(columnDefinition, false); int scale = Integer.parseInt(columnDefinition.substring(openPos + 1, commaPos)); int precision = Integer.parseInt(columnDefinition.substring(commaPos + 1, closePos)); return new DbPlatformType(type, scale, precision); return new DbPlatformType(type, scale); return new DbPlatformType(columnDefinition, false);
/** * Convert a type that has scale and possibly precision. */ protected String convertWithScale(String columnDefinition, int open) { int close = columnDefinition.lastIndexOf(')'); if (close == -1) { // assume already platform specific, leave as is return columnDefinition; } String suffix = close + 1 < columnDefinition.length() ? columnDefinition.substring(close + 1) : ""; String type = columnDefinition.substring(0, open); try { DbPlatformType dbType = platformTypes.lookup(type, true); int comma = columnDefinition.indexOf(',', open); if (comma > -1) { // scale and precision - decimal(10,4) int scale = Integer.parseInt(columnDefinition.substring(open + 1, comma)); int precision = Integer.parseInt(columnDefinition.substring(comma + 1, close)); return dbType.renderType(scale, precision) + suffix; } else { // scale - varchar(10) int scale = Integer.parseInt(columnDefinition.substring(open + 1, close)); return dbType.renderType(scale, 0) + suffix; } } catch (IllegalArgumentException e) { // assume already platform specific, leave as is return columnDefinition; } }
public SqlAnywherePlatform() { super(); this.platform = Platform.SQLANYWHERE; this.dbIdentity.setIdType(IdType.IDENTITY); this.sqlLimiter = new SqlAnywhereLimiter(); this.dbIdentity.setSupportsGetGeneratedKeys(false); this.dbIdentity.setSelectLastInsertedIdTemplate("select @@IDENTITY as X"); this.dbIdentity.setSupportsIdentity(true); dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("bit default 0")); dbTypeMap.put(DbType.BIGINT, new DbPlatformType("numeric", 19)); dbTypeMap.put(DbType.REAL, new DbPlatformType("float(16)")); dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("float(32)")); dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint")); dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("numeric", 28)); dbTypeMap.put(DbType.BLOB, new DbPlatformType("binary(4500)")); dbTypeMap.put(DbType.CLOB, new DbPlatformType("long varchar")); dbTypeMap.put(DbType.LONGVARBINARY, new DbPlatformType("long binary")); dbTypeMap.put(DbType.LONGVARCHAR, new DbPlatformType("long varchar")); }
String discDbType = dbType.renderType(inheritInfo.getDiscriminatorLength(), 0);
public SQLitePlatform() { super(); this.platform = Platform.SQLITE; this.platformDdl = new SQLiteDdl(this); this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsGetGeneratedKeys(false); this.dbIdentity.setSupportsSequence(false); this.dbIdentity.setSelectLastInsertedIdTemplate("select last_insert_rowid()"); this.booleanDbType = Types.INTEGER; dbTypeMap.put(DbType.BIT, new DbPlatformType("int default 0")); dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("int default 0")); dbTypeMap.put(DbType.BIGINT, new DbPlatformType("integer")); dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("integer")); }
public DB2Platform() { super(); this.platform = Platform.DB2; this.maxTableNameLength = 18; this.maxConstraintNameLength = 18; this.sqlLimiter = new Db2SqlLimiter(); this.platformDdl = new DB2Ddl(this); this.dbIdentity.setSupportsGetGeneratedKeys(true); this.dbIdentity.setSupportsSequence(true); booleanDbType = Types.BOOLEAN; dbTypeMap.put(DbType.REAL, new DbPlatformType("real")); dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint")); dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("decimal", 15)); }
this.closeQuote = "]"; dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("bit default 0")); dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false)); dbTypeMap.put(DbType.BIGINT, new DbPlatformType("numeric", 19)); dbTypeMap.put(DbType.REAL, new DbPlatformType("float(16)")); dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("float(32)")); dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint")); dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("numeric", 28)); dbTypeMap.put(DbType.BLOB, new DbPlatformType("image")); dbTypeMap.put(DbType.CLOB, new DbPlatformType("text")); dbTypeMap.put(DbType.LONGVARBINARY, new DbPlatformType("image")); dbTypeMap.put(DbType.LONGVARCHAR, new DbPlatformType("text")); dbTypeMap.put(DbType.DATE, new DbPlatformType("date")); dbTypeMap.put(DbType.TIME, new DbPlatformType("time")); dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("datetime2"));
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("number(1) default 0")); dbTypeMap.put(DbType.INTEGER, new DbPlatformType("number", 10)); dbTypeMap.put(DbType.BIGINT, new DbPlatformType("number", 19)); dbTypeMap.put(DbType.REAL, new DbPlatformType("number", 19, 4)); dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("number", 19, 4)); dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("number", 5)); dbTypeMap.put(DbType.TINYINT, new DbPlatformType("number", 3)); dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("number", 38)); dbTypeMap.put(DbType.VARCHAR, new DbPlatformType("varchar2", 255)); dbTypeMap.put(DbType.LONGVARBINARY, new DbPlatformType("blob")); dbTypeMap.put(DbType.LONGVARCHAR, new DbPlatformType("clob")); dbTypeMap.put(DbType.VARBINARY, new DbPlatformType("raw", 255)); dbTypeMap.put(DbType.BINARY, new DbPlatformType("raw", 255)); dbTypeMap.put(DbType.TIME, new DbPlatformType("timestamp"));
this.closeQuote = "\""; DbPlatformType dbTypeText = new DbPlatformType("text", false); DbPlatformType dbBytea = new DbPlatformType("bytea", false); dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false)); dbTypeMap.put(DbType.HSTORE, new DbPlatformType("hstore", false)); dbTypeMap.put(DbType.JSON, new DbPlatformType("json", false)); dbTypeMap.put(DbType.JSONB, new DbPlatformType("jsonb", false)); dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false)); dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("float")); dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint")); dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("decimal", 38)); dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("timestamptz"));
public MySqlPlatform() { super(); this.platform = Platform.MYSQL; this.useExtraTransactionOnIterateSecondaryQueries = true; this.likeClause = "like ? escape''"; this.selectCountWithAlias = true; this.dbEncrypt = new MySqlDbEncrypt(); this.platformDdl = new MySqlDdl(this); this.historySupport = new MySqlHistorySupport(); this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsGetGeneratedKeys(true); this.dbIdentity.setSupportsIdentity(true); this.dbIdentity.setSupportsSequence(false); this.openQuote = "`"; this.closeQuote = "`"; this.forwardOnlyHintOnFindIterate = true; this.booleanDbType = Types.BIT; dbTypeMap.put(DbType.BIT, new DbPlatformType("tinyint(1) default 0")); dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("tinyint(1) default 0")); dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("datetime(6)")); dbTypeMap.put(DbType.CLOB, new MySqlClob()); dbTypeMap.put(DbType.BLOB, new MySqlBlob()); dbTypeMap.put(DbType.BINARY, new DbPlatformType("binary", 255)); dbTypeMap.put(DbType.VARBINARY, new DbPlatformType("varbinary", 255)); }
public HsqldbPlatform() { super(); this.platform = Platform.HSQLDB; this.dbEncrypt = new H2DbEncrypt(); this.platformDdl = new HsqldbDdl(this); this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsGetGeneratedKeys(true); this.dbIdentity.setSupportsSequence(true); this.dbIdentity.setSupportsIdentity(true); dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false)); }