From 5bb94e23629b0b9a2777cfd9ae3f7284cc25a9fd Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 3 Oct 2007 04:54:42 +0000 Subject: [PATCH] HHH-2593 : filter conditions using UNION (or MINUS) subqueries git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14052 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../main/java/org/hibernate/sql/Template.java | 4 ++- .../hibernate/test/filter/Category.hbm.xml | 27 ++++++++++--------- .../test/filter/DynamicFilterTest.java | 7 +++++ .../org/hibernate/test/filter/defs.hbm.xml | 4 +++ 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/hibernate/sql/Template.java b/core/src/main/java/org/hibernate/sql/Template.java index 81065fdac3..fdb808c9e9 100644 --- a/core/src/main/java/org/hibernate/sql/Template.java +++ b/core/src/main/java/org/hibernate/sql/Template.java @@ -48,7 +48,9 @@ public final class Template { KEYWORDS.add("some"); KEYWORDS.add("exists"); KEYWORDS.add("all"); - + KEYWORDS.add("union"); + KEYWORDS.add("minus"); + BEFORE_TABLE_KEYWORDS.add("from"); BEFORE_TABLE_KEYWORDS.add("join"); diff --git a/testsuite/src/test/java/org/hibernate/test/filter/Category.hbm.xml b/testsuite/src/test/java/org/hibernate/test/filter/Category.hbm.xml index 422875babb..42b78bf479 100644 --- a/testsuite/src/test/java/org/hibernate/test/filter/Category.hbm.xml +++ b/testsuite/src/test/java/org/hibernate/test/filter/Category.hbm.xml @@ -6,21 +6,24 @@ - - - + + + - - - + + + - - - - + + + + - + + + 'abc' in ( select d.reg from department d where (d.dept_id=123) union select p.name from sales_person p ) + - + \ No newline at end of file diff --git a/testsuite/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java b/testsuite/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java index 0d7082118a..4c6f92e1b5 100644 --- a/testsuite/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java +++ b/testsuite/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java @@ -65,6 +65,13 @@ public class DynamicFilterTest extends FunctionalTestCase { return new FunctionalTestClassTestSuite( DynamicFilterTest.class ); } + public void testSqlSyntaxOfFiltersWithUnions() { + Session session = openSession(); + session.enableFilter( "unioned" ); + session.createQuery( "from Category" ).list(); + session.close(); + } + public void testSecondLevelCachedCollectionsFiltering() { TestData testData = new TestData(); testData.prepare(); diff --git a/testsuite/src/test/java/org/hibernate/test/filter/defs.hbm.xml b/testsuite/src/test/java/org/hibernate/test/filter/defs.hbm.xml index f9305a83d2..dca3bce0b5 100644 --- a/testsuite/src/test/java/org/hibernate/test/filter/defs.hbm.xml +++ b/testsuite/src/test/java/org/hibernate/test/filter/defs.hbm.xml @@ -27,4 +27,8 @@ + + + + \ No newline at end of file