public CreateSequenceVisitor(DdlGenContext ctx) { this.ctx = ctx; this.supportsSequence = ctx.getDbPlatform().getDbIdentity().isSupportsSequence(); }
public Postgres8Platform() { super(); this.dbIdentity.setSupportsGetGeneratedKeys(false); this.dbIdentity.setIdType(IdType.SEQUENCE); this.dbIdentity.setSupportsSequence(true); this.dbIdentity.setSupportsIdentity(true); this.columnAliasPrefix = "as c"; }
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 SQLitePlatform(){ super(); this.name = "sqlite"; this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsGetGeneratedKeys(false); this.dbIdentity.setSelectLastInsertedIdTemplate("select last_insert_rowid()"); this.openQuote = "\""; this.closeQuote = "\""; this.booleanDbType = Types.INTEGER; dbTypeMap.put(Types.BIT, new DbType("int default 0")); dbTypeMap.put(Types.BOOLEAN, new DbType("int default 0")); dbDdlSyntax.setInlinePrimaryKeyConstraint(true); dbDdlSyntax.setIdentity("AUTOINCREMENT"); dbDdlSyntax.setDisableReferentialIntegrity("PRAGMA foreign_keys = OFF"); dbDdlSyntax.setEnableReferentialIntegrity("PRAGMA foreign_keys = ON"); }
public SqlAnywherePlatform() { super(); this.name = "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(Types.BOOLEAN, new DbType("bit default 0")); dbTypeMap.put(Types.BIGINT, new DbType("numeric", 19)); dbTypeMap.put(Types.REAL, new DbType("float(16)")); dbTypeMap.put(Types.DOUBLE, new DbType("float(32)")); dbTypeMap.put(Types.TINYINT, new DbType("smallint")); dbTypeMap.put(Types.DECIMAL, new DbType("numeric", 28)); dbTypeMap.put(Types.BLOB, new DbType("binary(4500)")); dbTypeMap.put(Types.CLOB, new DbType("long varchar")); dbTypeMap.put(Types.LONGVARBINARY, new DbType("long binary")); dbTypeMap.put(Types.LONGVARCHAR, new DbType("long varchar")); }
public DB2Platform(){ super(); this.name = "db2"; // only support getGeneratedKeys with non-batch JDBC // so generally use SEQUENCE instead for H2 this.dbIdentity.setSupportsGetGeneratedKeys(true); this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsSequence(true); this.openQuote = "\""; this.closeQuote = "\""; booleanDbType = Types.INTEGER; dbTypeMap.put(Types.BOOLEAN, new DbType("smallint default 0")); dbTypeMap.put(Types.INTEGER, new DbType("integer")); dbTypeMap.put(Types.BIGINT, new DbType("bigint")); dbTypeMap.put(Types.REAL, new DbType("float")); dbTypeMap.put(Types.DOUBLE, new DbType("float")); dbTypeMap.put(Types.SMALLINT, new DbType("smallint")); dbTypeMap.put(Types.TINYINT, new DbType("smallint")); dbTypeMap.put(Types.DECIMAL, new DbType("decimal", 15)); this.dbDdlSyntax.setIdentity("generated by default as identity"); //this.dbDdlSyntax.setDropIfExists("if exists"); //this.dbDdlSyntax.setDisableReferentialIntegrity("SET REFERENTIAL_INTEGRITY FALSE"); //this.dbDdlSyntax.setEnableReferentialIntegrity("SET REFERENTIAL_INTEGRITY TRUE"); //this.dbDdlSyntax.setForeignKeySuffix("on delete restrict on update restrict"); }
if (IdType.SEQUENCE.equals(desc.getIdType()) && !dbIdentity.isSupportsSequence()) { if (IdType.IDENTITY.equals(desc.getIdType()) && !dbIdentity.isSupportsIdentity()) { desc.setIdType(dbIdentity.getIdType()); String selectLastInsertedId = dbIdentity.getSelectLastInsertedId(desc.getBaseTable()); desc.setSelectLastInsertedId(selectLastInsertedId); return IdType.IDENTITY;
public MsSqlServer2005Platform() { super(); this.name = "mssqlserver2005"; this.sqlLimiter = new MsSqlServer2005SqlLimiter(); this.dbDdlSyntax.setIdentity("identity(1,1)"); this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsGetGeneratedKeys(true); this.dbIdentity.setSupportsIdentity(true); this.openQuote = "["; this.closeQuote = "]"; dbTypeMap.put(Types.BOOLEAN, new DbType("bit default 0")); dbTypeMap.put(Types.BIGINT, new DbType("numeric", 19)); dbTypeMap.put(Types.REAL, new DbType("float(16)")); dbTypeMap.put(Types.DOUBLE, new DbType("float(32)")); dbTypeMap.put(Types.TINYINT, new DbType("smallint")); dbTypeMap.put(Types.DECIMAL, new DbType("numeric", 28)); dbTypeMap.put(Types.BLOB, new DbType("image")); dbTypeMap.put(Types.CLOB, new DbType("text")); dbTypeMap.put(Types.LONGVARBINARY, new DbType("image")); dbTypeMap.put(Types.LONGVARCHAR, new DbType("text")); dbTypeMap.put(Types.DATE, new DbType("datetime")); dbTypeMap.put(Types.TIME, new DbType("datetime")); dbTypeMap.put(Types.TIMESTAMP, new DbType("datetime")); }
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)); }
public InsertMeta(DatabasePlatform dbPlatform, BeanDescriptor<?> desc, Bindable shadowFKey, BindableId id, Bindable all) { this.emptyStringToNull = dbPlatform.isTreatEmptyStringsAsNull(); this.tableName = desc.getBaseTable(); this.discriminator = getDiscriminator(desc); this.id = id; this.all = all; this.shadowFKey = shadowFKey; this.sqlWithId = genSql(false, null); // only available for single Id property if (id.isConcatenated()) { // concatenated key this.concatinatedKey = true; this.identityDbColumns = null; this.sqlNullId = null; this.supportsGetGeneratedKeys = false; this.selectLastInsertedId = null; } else { // insert sql for db identity or sequence insert this.concatinatedKey = false; this.identityDbColumns = new String[]{id.getIdentityColumn()}; this.sqlNullId = genSql(true, null); this.supportsGetGeneratedKeys = dbPlatform.getDbIdentity().isSupportsGetGeneratedKeys(); this.selectLastInsertedId = desc.getSelectLastInsertedId(); } }
protected void configureIdType(IdType idType) { if (idType != null) { this.dbIdentity.setIdType(idType); } }
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")); }
public DB2Platform() { super(); this.name = "db2"; // only support getGeneratedKeys with non-batch JDBC // so generally use SEQUENCE instead for H2 this.dbIdentity.setSupportsGetGeneratedKeys(true); this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsSequence(true); this.openQuote = "\""; this.closeQuote = "\""; booleanDbType = Types.INTEGER; dbTypeMap.put(Types.BOOLEAN, new DbType("smallint default 0")); dbTypeMap.put(Types.INTEGER, new DbType("integer")); dbTypeMap.put(Types.BIGINT, new DbType("bigint")); dbTypeMap.put(Types.REAL, new DbType("float")); dbTypeMap.put(Types.DOUBLE, new DbType("float")); dbTypeMap.put(Types.SMALLINT, new DbType("smallint")); dbTypeMap.put(Types.TINYINT, new DbType("smallint")); dbTypeMap.put(Types.DECIMAL, new DbType("decimal", 15)); this.dbDdlSyntax.setIdentity("generated by default as identity"); // this.dbDdlSyntax.setDropIfExists("if exists"); // this.dbDdlSyntax.setDisableReferentialIntegrity("SET REFERENTIAL_INTEGRITY FALSE"); // this.dbDdlSyntax.setEnableReferentialIntegrity("SET REFERENTIAL_INTEGRITY TRUE"); // this.dbDdlSyntax.setForeignKeySuffix("on delete restrict on update restrict"); }
if (IdType.SEQUENCE.equals(desc.getIdType()) && !dbIdentity.isSupportsSequence()) { if (IdType.IDENTITY.equals(desc.getIdType()) && !dbIdentity.isSupportsIdentity()) { desc.setIdType(dbIdentity.getIdType()); String selectLastInsertedId = dbIdentity.getSelectLastInsertedId(desc.getBaseTable()); desc.setSelectLastInsertedId(selectLastInsertedId); return IdType.IDENTITY;
public MsSqlServer2005Platform(){ super(); this.name = "mssqlserver2005"; this.sqlLimiter = new MsSqlServer2005SqlLimiter(); this.dbDdlSyntax.setIdentity("identity(1,1)"); this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsGetGeneratedKeys(true); this.dbIdentity.setSupportsIdentity(true); this.openQuote = "["; this.closeQuote = "]"; dbTypeMap.put(Types.BOOLEAN, new DbType("bit default 0")); dbTypeMap.put(Types.BIGINT, new DbType("numeric", 19)); dbTypeMap.put(Types.REAL, new DbType("float(16)")); dbTypeMap.put(Types.DOUBLE, new DbType("float(32)")); dbTypeMap.put(Types.TINYINT, new DbType("smallint")); dbTypeMap.put(Types.DECIMAL, new DbType("numeric", 28)); dbTypeMap.put(Types.BLOB, new DbType("image")); dbTypeMap.put(Types.CLOB, new DbType("text")); dbTypeMap.put(Types.LONGVARBINARY, new DbType("image")); dbTypeMap.put(Types.LONGVARCHAR, new DbType("text")); dbTypeMap.put(Types.DATE, new DbType("datetime")); dbTypeMap.put(Types.TIME, new DbType("datetime")); dbTypeMap.put(Types.TIMESTAMP, new DbType("datetime")); }
public SQLitePlatform() { super(); this.name = "sqlite"; this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsGetGeneratedKeys(false); this.dbIdentity.setSelectLastInsertedIdTemplate("select last_insert_rowid()"); this.openQuote = "\""; this.closeQuote = "\""; this.booleanDbType = Types.INTEGER; dbTypeMap.put(Types.BIT, new DbType("int default 0")); dbTypeMap.put(Types.BOOLEAN, new DbType("int default 0")); dbDdlSyntax.setInlinePrimaryKeyConstraint(true); dbDdlSyntax.setIdentity("AUTOINCREMENT"); dbDdlSyntax.setDisableReferentialIntegrity("PRAGMA foreign_keys = OFF"); dbDdlSyntax.setEnableReferentialIntegrity("PRAGMA foreign_keys = ON"); }
public InsertMeta(DatabasePlatform dbPlatform, BeanDescriptor<?> desc, Bindable shadowFKey, BindableId id, Bindable all) { this.emptyStringToNull = dbPlatform.isTreatEmptyStringsAsNull(); this.tableName = desc.getBaseTable(); this.discriminator = getDiscriminator(desc); this.id = id; this.all = all; this.shadowFKey = shadowFKey; this.sqlWithId = genSql(false, null); // only available for single Id property if (id.isConcatenated()) { // concatenated key this.concatinatedKey = true; this.identityDbColumns = null; this.sqlNullId = null; this.supportsGetGeneratedKeys = false; this.selectLastInsertedId = null; } else { // insert sql for db identity or sequence insert this.concatinatedKey = false; this.identityDbColumns = new String[]{id.getIdentityColumn()}; this.sqlNullId = genSql(true, null); this.supportsGetGeneratedKeys = dbPlatform.getDbIdentity().isSupportsGetGeneratedKeys(); this.selectLastInsertedId = desc.getSelectLastInsertedId(); } }
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)); }
public SqlAnywherePlatform() { super(); this.name = "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(Types.BOOLEAN, new DbType("bit default 0")); dbTypeMap.put(Types.BIGINT, new DbType("numeric", 19)); dbTypeMap.put(Types.REAL, new DbType("float(16)")); dbTypeMap.put(Types.DOUBLE, new DbType("float(32)")); dbTypeMap.put(Types.TINYINT, new DbType("smallint")); dbTypeMap.put(Types.DECIMAL, new DbType("numeric", 28)); dbTypeMap.put(Types.BLOB, new DbType("binary(4500)")); dbTypeMap.put(Types.CLOB, new DbType("long varchar")); dbTypeMap.put(Types.LONGVARBINARY, new DbType("long binary")); dbTypeMap.put(Types.LONGVARCHAR, new DbType("long varchar")); }
this.dbIdentity.setSupportsGetGeneratedKeys(false); this.dbIdentity.setIdType(IdType.SEQUENCE); this.dbIdentity.setSupportsSequence(true);