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
This commit is contained in:
Steve Ebersole 2007-10-03 04:54:42 +00:00
parent 430a94b5ab
commit 5bb94e2362
4 changed files with 29 additions and 13 deletions

View File

@ -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");

View File

@ -6,21 +6,24 @@
<hibernate-mapping package="org.hibernate.test.filter">
<class name="Category" table="CATEGORY">
<id name="id" column="CAT_ID" >
<generator class="native"/>
</id>
<id name="id" column="CAT_ID">
<generator class="native"/>
</id>
<property name="name" type="string"/>
<property name="effectiveStartDate" column="eff_start_dt" type="java.util.Date"/>
<property name="effectiveEndDate" column="eff_end_dt" type="java.util.Date"/>
<property name="name" type="string"/>
<property name="effectiveStartDate" column="eff_start_dt" type="java.util.Date"/>
<property name="effectiveEndDate" column="eff_end_dt" type="java.util.Date"/>
<set cascade="none" inverse="true" name="products" table="PROD_CAT">
<key column="CAT_ID"/>
<many-to-many column="PROD_ID" class="Product"/>
</set>
<set cascade="none" inverse="true" name="products" table="PROD_CAT">
<key column="CAT_ID"/>
<many-to-many column="PROD_ID" class="Product"/>
</set>
<filter name="effectiveDate" condition=":asOfDate BETWEEN eff_start_dt and eff_end_dt"/>
<filter name="effectiveDate" condition=":asOfDate BETWEEN eff_start_dt and eff_end_dt"/>
<filter name="unioned">
'abc' in ( select d.reg from department d where (d.dept_id=123) union select p.name from sales_person p )
</filter>
</class>
</class>
</hibernate-mapping>

View File

@ -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();

View File

@ -27,4 +27,8 @@
<filter-def name="cat">
<filter-param name="catId" type="long"/>
</filter-def>
<filter-def name="unioned">
</filter-def>
</hibernate-mapping>