HHH-10331 - Fix HSQLDialect returns supportsTupleDistinctCounts false which seems wrong

This commit is contained in:
Andrea Boriero 2015-12-07 17:06:58 +00:00
parent 86c0746c0b
commit 4b4164f8e0
2 changed files with 24 additions and 22 deletions

View File

@ -74,7 +74,7 @@ public class HSQLDialect extends Dialect {
@Override
public String processSql(String sql, RowSelection selection) {
final boolean hasOffset = LimitHelper.hasFirstRow( selection );
if (hsqldbVersion < 20) {
if ( hsqldbVersion < 200 ) {
return new StringBuilder( sql.length() + 10 )
.append( sql )
.insert(
@ -95,14 +95,14 @@ public class HSQLDialect extends Dialect {
@Override
public boolean bindLimitParametersFirst() {
return hsqldbVersion < 20;
return hsqldbVersion < 200;
}
}
/**
* version is 18 for 1.8 or 20 for 2.0
* version is 180 for 1.8.0 or 200 for 2.0.0
*/
private int hsqldbVersion = 18;
private int hsqldbVersion = 180;
private final LimitHandler limitHandler;
@ -116,8 +116,9 @@ public class HSQLDialect extends Dialect {
final Class props = ReflectHelper.classForName( "org.hsqldb.persist.HsqlDatabaseProperties" );
final String versionString = (String) props.getDeclaredField( "THIS_VERSION" ).get( null );
hsqldbVersion = Integer.parseInt( versionString.substring( 0, 1 ) ) * 10;
hsqldbVersion += Integer.parseInt( versionString.substring( 2, 3 ) );
hsqldbVersion = Integer.parseInt( versionString.substring( 0, 1 ) ) * 100;
hsqldbVersion += Integer.parseInt( versionString.substring( 2, 3 ) ) * 10;
hsqldbVersion += Integer.parseInt( versionString.substring( 4, 5 ) );
}
catch ( Throwable e ) {
// must be a very old version
@ -143,7 +144,7 @@ public class HSQLDialect extends Dialect {
registerColumnType( Types.VARCHAR, "varchar($l)" );
registerColumnType( Types.VARBINARY, "varbinary($l)" );
if ( hsqldbVersion < 20 ) {
if ( hsqldbVersion < 200 ) {
registerColumnType( Types.NUMERIC, "numeric" );
}
else {
@ -151,7 +152,7 @@ public class HSQLDialect extends Dialect {
}
//HSQL has no Blob/Clob support .... but just put these here for now!
if ( hsqldbVersion < 20 ) {
if ( hsqldbVersion < 200 ) {
registerColumnType( Types.BLOB, "longvarbinary" );
registerColumnType( Types.CLOB, "longvarchar" );
}
@ -185,7 +186,7 @@ public class HSQLDialect extends Dialect {
registerFunction( "database", new NoArgSQLFunction( "database", StandardBasicTypes.STRING ) );
// datetime functions
if ( hsqldbVersion < 20 ) {
if ( hsqldbVersion < 200 ) {
registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", StandardBasicTypes.DATE, false ) );
}
else {
@ -242,7 +243,7 @@ public class HSQLDialect extends Dialect {
// special functions
// from v. 2.2.0 ROWNUM() is supported in all modes as the equivalent of Oracle ROWNUM
if ( hsqldbVersion > 21 ) {
if ( hsqldbVersion > 219 ) {
registerFunction( "rownum", new NoArgSQLFunction( "rownum", StandardBasicTypes.INTEGER ) );
}
@ -266,7 +267,7 @@ public class HSQLDialect extends Dialect {
@Override
public String getForUpdateString() {
if ( hsqldbVersion >= 20 ) {
if ( hsqldbVersion >= 200 ) {
return " for update";
}
else {
@ -286,7 +287,7 @@ public class HSQLDialect extends Dialect {
@Override
public String getLimitString(String sql, boolean hasOffset) {
if ( hsqldbVersion < 20 ) {
if ( hsqldbVersion < 200 ) {
return new StringBuilder( sql.length() + 10 )
.append( sql )
.insert(
@ -302,7 +303,7 @@ public class HSQLDialect extends Dialect {
@Override
public boolean bindLimitParametersFirst() {
return hsqldbVersion < 20;
return hsqldbVersion < 200;
}
@Override
@ -312,7 +313,7 @@ public class HSQLDialect extends Dialect {
@Override
public boolean supportsColumnCheck() {
return hsqldbVersion >= 20;
return hsqldbVersion >= 200;
}
@Override
@ -369,7 +370,7 @@ public class HSQLDialect extends Dialect {
@Override
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
return hsqldbVersion < 20 ? EXTRACTER_18 : EXTRACTER_20;
return hsqldbVersion < 200 ? EXTRACTER_18 : EXTRACTER_20;
}
private static final ViolatedConstraintNameExtracter EXTRACTER_18 = new TemplatedViolatedConstraintNameExtracter() {
@ -497,7 +498,7 @@ public class HSQLDialect extends Dialect {
// the definition and data is private to the session and table declaration
// can happen in the middle of a transaction
if ( hsqldbVersion < 20 ) {
if ( hsqldbVersion < 200 ) {
return new GlobalTemporaryTableBulkIdStrategy(
new IdTableSupportStandardImpl() {
@Override
@ -591,7 +592,7 @@ public class HSQLDialect extends Dialect {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
}
if ( hsqldbVersion < 20 ) {
if ( hsqldbVersion < 200 ) {
return new ReadUncommittedLockingStrategy( lockable, lockMode );
}
else {
@ -615,7 +616,7 @@ public class HSQLDialect extends Dialect {
@Override
public boolean supportsCommentOn() {
return hsqldbVersion >= 20;
return hsqldbVersion >= 200;
}
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -632,12 +633,12 @@ public class HSQLDialect extends Dialect {
@Override
public boolean doesReadCommittedCauseWritersToBlockReaders() {
return hsqldbVersion >= 20;
return hsqldbVersion >= 200;
}
@Override
public boolean doesRepeatableReadCauseReadersToBlockWriters() {
return hsqldbVersion >= 20;
return hsqldbVersion >= 200;
}
@Override
@ -652,7 +653,8 @@ public class HSQLDialect extends Dialect {
@Override
public boolean supportsTupleDistinctCounts() {
return false;
// from v. 2.2.9 is added support for COUNT(DISTINCT ...) with multiple arguments
return hsqldbVersion >= 229;
}
@Override

View File

@ -36,6 +36,6 @@ public class HSQLIdentityColumnSupport extends IdentityColumnSupportImpl {
@Override
public String getIdentityInsertString() {
return hsqldbVersion < 20 ? "null" : "default";
return hsqldbVersion < 200 ? "null" : "default";
}
}