diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLSqlAstTranslator.java index e6a1fd943c..96d36ae036 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLSqlAstTranslator.java @@ -242,12 +242,11 @@ public class HSQLSqlAstTranslator extends AbstractSqlAs } else { // HSQL does not like parameters in the distinct from predicate - render( lhs, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER ); - appendSql( operator.sqlText() ); - render( rhs, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER ); + renderComparisonEmulateIntersect( lhs, operator, rhs ); } break; default: + // HSQL has a broken 'is distinct from' operator renderComparisonStandard( lhs, operator, rhs ); break; } @@ -317,4 +316,5 @@ public class HSQLSqlAstTranslator extends AbstractSqlAs appendSql( CLOSE_PARENTHESIS ); } } + } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/DistinctFromTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/DistinctFromTest.java index 1b154e5c0d..2d2836e82e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/DistinctFromTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/DistinctFromTest.java @@ -121,12 +121,14 @@ public class DistinctFromTest { scope.inSession(session -> { assertEquals(1, session.createSelectionQuery("select 1 where 1 is distinct from 0").getResultList().size()); assertEquals(0, session.createSelectionQuery("select 1 where 1 is distinct from 1").getResultList().size()); + assertEquals(1, session.createSelectionQuery("select 1 where 1 is distinct from null").getResultList().size()); assertEquals(1, session.createSelectionQuery("select 1 where null is distinct from 1").getResultList().size()); assertEquals(1, session.createSelectionQuery("select 1 where null is distinct from 0").getResultList().size()); assertEquals(0, session.createSelectionQuery("select 1 where null is distinct from null").getResultList().size()); assertEquals(0, session.createSelectionQuery("select 1 where 1 is not distinct from 0").getResultList().size()); assertEquals(1, session.createSelectionQuery("select 1 where 1 is not distinct from 1").getResultList().size()); + assertEquals(0, session.createSelectionQuery("select 1 where 1 is not distinct from null").getResultList().size()); assertEquals(0, session.createSelectionQuery("select 1 where null is not distinct from 1").getResultList().size()); assertEquals(0, session.createSelectionQuery("select 1 where null is not distinct from 0").getResultList().size()); assertEquals(1, session.createSelectionQuery("select 1 where null is not distinct from null").getResultList().size());