HHH-14156 - handle all H2 versions properly regarding tuple in subquery syntax
This commit is contained in:
parent
be64851fee
commit
e1b821c6fb
|
@ -73,6 +73,7 @@ public class H2Dialect extends Dialect {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final boolean supportsTuplesInSubqueries;
|
||||||
private final String querySequenceString;
|
private final String querySequenceString;
|
||||||
private final SequenceInformationExtractor sequenceInformationExtractor;
|
private final SequenceInformationExtractor sequenceInformationExtractor;
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ public class H2Dialect extends Dialect {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
int buildId = Integer.MIN_VALUE;
|
int buildId = Integer.MIN_VALUE;
|
||||||
|
boolean supportsTuplesInSubqueries = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// HHH-2300
|
// HHH-2300
|
||||||
|
@ -94,6 +96,7 @@ public class H2Dialect extends Dialect {
|
||||||
if ( ! ( majorVersion > 1 || minorVersion > 2 || buildId >= 139 ) ) {
|
if ( ! ( majorVersion > 1 || minorVersion > 2 || buildId >= 139 ) ) {
|
||||||
LOG.unsupportedMultiTableBulkHqlJpaql( majorVersion, minorVersion, buildId );
|
LOG.unsupportedMultiTableBulkHqlJpaql( majorVersion, minorVersion, buildId );
|
||||||
}
|
}
|
||||||
|
supportsTuplesInSubqueries = majorVersion > 1 || minorVersion > 4 || buildId >= 198;
|
||||||
}
|
}
|
||||||
catch ( Exception e ) {
|
catch ( Exception e ) {
|
||||||
// probably H2 not in the classpath, though in certain app server environments it might just mean we are
|
// 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.sequenceInformationExtractor = SequenceInformationExtractorNoOpImpl.INSTANCE;
|
||||||
this.querySequenceString = null;
|
this.querySequenceString = null;
|
||||||
}
|
}
|
||||||
|
this.supportsTuplesInSubqueries = supportsTuplesInSubqueries;
|
||||||
|
|
||||||
registerColumnType( Types.BOOLEAN, "boolean" );
|
registerColumnType( Types.BOOLEAN, "boolean" );
|
||||||
registerColumnType( Types.BIGINT, "bigint" );
|
registerColumnType( Types.BIGINT, "bigint" );
|
||||||
|
@ -432,7 +436,7 @@ public class H2Dialect extends Dialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsTuplesInSubqueries() {
|
public boolean supportsTuplesInSubqueries() {
|
||||||
return false;
|
return supportsTuplesInSubqueries;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not drop constraints explicitly, just do this by cascading instead.
|
// Do not drop constraints explicitly, just do this by cascading instead.
|
||||||
|
|
|
@ -214,7 +214,7 @@ public class IdentNode extends FromReferenceNode implements SelectExpression {
|
||||||
final boolean shouldSkipWrappingInParenthesis =
|
final boolean shouldSkipWrappingInParenthesis =
|
||||||
(isInDistinctCount && ! dialect.requiresParensForTupleDistinctCounts())
|
(isInDistinctCount && ! dialect.requiresParensForTupleDistinctCounts())
|
||||||
|| isInNonDistinctCount
|
|| isInNonDistinctCount
|
||||||
|| getWalker().isInSelect() && !getWalker().isInCase() && !isInCount // HHH-14156
|
|| getWalker().isInSelect() && !getWalker().isInCase() && !isInCount && dialect.supportsTuplesInSubqueries() // HHH-14156
|
||||||
|| getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.ORDER
|
|| getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.ORDER
|
||||||
|| getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.GROUP;
|
|| getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.GROUP;
|
||||||
if ( ! shouldSkipWrappingInParenthesis ) {
|
if ( ! shouldSkipWrappingInParenthesis ) {
|
||||||
|
|
|
@ -7,9 +7,6 @@ import javax.persistence.EmbeddedId;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -19,7 +16,6 @@ import org.junit.Test;
|
||||||
* @author Christian Beikov
|
* @author Christian Beikov
|
||||||
*/
|
*/
|
||||||
@TestForIssue( jiraKey = "HHH-14156" )
|
@TestForIssue( jiraKey = "HHH-14156" )
|
||||||
@RequiresDialect( PostgreSQL82Dialect.class )
|
|
||||||
public class HHH14156Test extends BaseCoreFunctionalTestCase {
|
public class HHH14156Test extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue