As suggested by @romainmoreau and @aklish, use 'cascade' in H2 1.4.200+
See https://github.com/hibernate/hibernate-orm/pull/3093 Also fix up some confusing/wrong handling of H2 version numbers and delete some obsolete commented code.
This commit is contained in:
parent
844adb4d45
commit
bb10a8ce27
|
@ -56,10 +56,7 @@ public class H2Dialect extends Dialect {
|
||||||
|
|
||||||
private final LimitHandler limitHandler;
|
private final LimitHandler limitHandler;
|
||||||
|
|
||||||
private final boolean dropConstraints;
|
private final boolean cascadeConstraints;
|
||||||
|
|
||||||
// private final String querySequenceString;
|
|
||||||
// private final SequenceInformationExtractor sequenceInformationExtractor;
|
|
||||||
|
|
||||||
public H2Dialect() {
|
public H2Dialect() {
|
||||||
this(0, 0);
|
this(0, 0);
|
||||||
|
@ -68,30 +65,20 @@ public class H2Dialect extends Dialect {
|
||||||
public H2Dialect(int version, int buildId) {
|
public H2Dialect(int version, int buildId) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
limitHandler = !( version > 140 || buildId >= 199 )
|
//TODO: actually I think all builds of 1.4 support OFFSET FETCH
|
||||||
? LimitOffsetLimitHandler.INSTANCE
|
limitHandler = version > 140 || version == 140 && buildId >= 199
|
||||||
: OffsetFetchLimitHandler.INSTANCE;
|
? OffsetFetchLimitHandler.INSTANCE
|
||||||
|
: LimitOffsetLimitHandler.INSTANCE;
|
||||||
// if ( buildId >= 32 ) {
|
|
||||||
// this.sequenceInformationExtractor = SequenceInformationExtractorH2DatabaseImpl.INSTANCE;
|
|
||||||
// this.querySequenceString = "select * from information_schema.sequences";
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// this.sequenceInformationExtractor = SequenceInformationExtractorNoOpImpl.INSTANCE;
|
|
||||||
// this.querySequenceString = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//Note: H2 'bit' is a synonym for 'boolean', not a proper bit type
|
//Note: H2 'bit' is a synonym for 'boolean', not a proper bit type
|
||||||
// registerColumnType( Types.BIT, "bit" );
|
// registerColumnType( Types.BIT, "bit" );
|
||||||
|
|
||||||
if ( !( version > 120 || buildId >= 139 ) ) {
|
if ( version < 120 || version == 120 && buildId < 139 ) {
|
||||||
LOG.unsupportedMultiTableBulkHqlJpaql( version / 100, version % 100 / 10, buildId );
|
LOG.unsupportedMultiTableBulkHqlJpaql( version / 100, version % 100 / 10, buildId );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prior to 1.4.200 we didn't need to drop constraints before
|
// Prior to 1.4.200 the 'cascade' in 'drop table' was implicit
|
||||||
// dropping tables, that just lead to error messages about
|
cascadeConstraints = version > 140 || version == 140 && buildId >= 200;
|
||||||
// missing tables when we don't have a schema in the database
|
|
||||||
dropConstraints = version > 140 && buildId >= 200;
|
|
||||||
|
|
||||||
getDefaultProperties().setProperty( AvailableSettings.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
getDefaultProperties().setProperty( AvailableSettings.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
||||||
// http://code.google.com/p/h2database/issues/detail?id=235
|
// http://code.google.com/p/h2database/issues/detail?id=235
|
||||||
|
@ -195,12 +182,17 @@ public class H2Dialect extends Dialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsAfterTableName() {
|
public boolean supportsIfExistsAfterTableName() {
|
||||||
return true;
|
return !supportsIfExistsBeforeTableName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsIfExistsBeforeTableName() {
|
||||||
|
return cascadeConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsAfterAlterTable() {
|
public boolean supportsIfExistsAfterAlterTable() {
|
||||||
return dropConstraints;
|
return cascadeConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -208,6 +200,17 @@ public class H2Dialect extends Dialect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCascadeConstraintsString() {
|
||||||
|
return cascadeConstraints ? " cascade "
|
||||||
|
: super.getCascadeConstraintsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dropConstraints() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceSupport getSequenceSupport() {
|
public SequenceSupport getSequenceSupport() {
|
||||||
return H2SequenceSupport.INSTANCE;
|
return H2SequenceSupport.INSTANCE;
|
||||||
|
@ -342,11 +345,6 @@ public class H2Dialect extends Dialect {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dropConstraints() {
|
|
||||||
return dropConstraints;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdentityColumnSupport getIdentityColumnSupport() {
|
public IdentityColumnSupport getIdentityColumnSupport() {
|
||||||
return new H2IdentityColumnSupport();
|
return new H2IdentityColumnSupport();
|
||||||
|
|
Loading…
Reference in New Issue