HHH-14156 - handle all H2 versions properly regarding tuple in subquery syntax

This commit is contained in:
Christian Beikov 2020-08-18 11:38:20 +02:00
parent be64851fee
commit e1b821c6fb
3 changed files with 6 additions and 6 deletions

View File

@ -73,6 +73,7 @@ public class H2Dialect extends Dialect {
}
};
private final boolean supportsTuplesInSubqueries;
private final String querySequenceString;
private final SequenceInformationExtractor sequenceInformationExtractor;
@ -83,6 +84,7 @@ public class H2Dialect extends Dialect {
super();
int buildId = Integer.MIN_VALUE;
boolean supportsTuplesInSubqueries = false;
try {
// HHH-2300
@ -94,6 +96,7 @@ public class H2Dialect extends Dialect {
if ( ! ( majorVersion > 1 || minorVersion > 2 || buildId >= 139 ) ) {
LOG.unsupportedMultiTableBulkHqlJpaql( majorVersion, minorVersion, buildId );
}
supportsTuplesInSubqueries = majorVersion > 1 || minorVersion > 4 || buildId >= 198;
}
catch ( Exception e ) {
// probably H2 not in the classpath, though in certain app server environments it might just mean we are
@ -111,6 +114,7 @@ public class H2Dialect extends Dialect {
this.sequenceInformationExtractor = SequenceInformationExtractorNoOpImpl.INSTANCE;
this.querySequenceString = null;
}
this.supportsTuplesInSubqueries = supportsTuplesInSubqueries;
registerColumnType( Types.BOOLEAN, "boolean" );
registerColumnType( Types.BIGINT, "bigint" );
@ -432,7 +436,7 @@ public class H2Dialect extends Dialect {
@Override
public boolean supportsTuplesInSubqueries() {
return false;
return supportsTuplesInSubqueries;
}
// Do not drop constraints explicitly, just do this by cascading instead.

View File

@ -214,7 +214,7 @@ public class IdentNode extends FromReferenceNode implements SelectExpression {
final boolean shouldSkipWrappingInParenthesis =
(isInDistinctCount && ! dialect.requiresParensForTupleDistinctCounts())
|| isInNonDistinctCount
|| getWalker().isInSelect() && !getWalker().isInCase() && !isInCount // HHH-14156
|| getWalker().isInSelect() && !getWalker().isInCase() && !isInCount && dialect.supportsTuplesInSubqueries() // HHH-14156
|| getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.ORDER
|| getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.GROUP;
if ( ! shouldSkipWrappingInParenthesis ) {

View File

@ -7,9 +7,6 @@ import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
@ -19,7 +16,6 @@ import org.junit.Test;
* @author Christian Beikov
*/
@TestForIssue( jiraKey = "HHH-14156" )
@RequiresDialect( PostgreSQL82Dialect.class )
public class HHH14156Test extends BaseCoreFunctionalTestCase {
@Override