77package org .hibernate .test .hql ;
88
99import java .util .ArrayList ;
10- import java .util .Collections ;
1110import java .util .HashMap ;
1211import java .util .List ;
1312
1716import org .hibernate .Session ;
1817import org .hibernate .Transaction ;
1918import org .hibernate .cfg .AvailableSettings ;
20- import org .hibernate .hql .internal .ast .InvalidWithClauseException ;
2119
2220import org .hibernate .testing .TestForIssue ;
2321import org .hibernate .testing .junit4 .BaseCoreFunctionalTestCase ;
@@ -66,43 +64,6 @@ public void testWithClauseFailsWithFetch() {
6664 data .cleanup ();
6765 }
6866
69- @ Test
70- public void testInvalidWithSemantics () {
71- Session s = openSession ();
72- Transaction txn = s .beginTransaction ();
73-
74- try {
75- // PROBLEM : f.bodyWeight is a reference to a column on the Animal table; however, the 'f'
76- // alias relates to the Human.friends collection which the aonther Human entity. The issue
77- // here is the way JoinSequence and Joinable (the persister) interact to generate the
78- // joins relating to the sublcass/superclass tables
79- s .createQuery ( "from Human h inner join h.friends as f with f.bodyWeight < :someLimit" )
80- .setDouble ( "someLimit" , 1 )
81- .list ();
82- fail ( "failure expected" );
83- }
84- catch (IllegalArgumentException e ) {
85- assertTyping ( QueryException .class , e .getCause () );
86- }
87- catch ( InvalidWithClauseException expected ) {
88- }
89-
90- try {
91- s .createQuery ( "from Human h inner join h.offspring o with o.mother.father = :cousin" )
92- .setEntity ( "cousin" , s .load ( Human .class , new Long (123 ) ) )
93- .list ();
94- fail ( "failure expected" );
95- }
96- catch (IllegalArgumentException e ) {
97- assertTyping ( QueryException .class , e .getCause () );
98- }
99- catch ( InvalidWithClauseException expected ) {
100- }
101-
102- txn .commit ();
103- s .close ();
104- }
105-
10667 @ Test
10768 public void testWithClause () {
10869 TestData data = new TestData ();
@@ -123,6 +84,11 @@ public void testWithClause() {
12384 .list ();
12485 assertTrue ( "ad-hoc on did not take effect" , list .isEmpty () );
12586
87+ list = s .createQuery ( "from Human h inner join h.friends f with f.bodyWeight < :someLimit" )
88+ .setDouble ( "someLimit" , 25 )
89+ .list ();
90+ assertTrue ( "ad-hoc on did take effect" , !list .isEmpty () );
91+
12692 // many-to-many
12793 list = s .createQuery ( "from Human h inner join h.friends as f with f.nickName like 'bubba'" )
12894 .list ();
@@ -133,6 +99,11 @@ public void testWithClause() {
13399 .list ();
134100 assertTrue ( "ad-hoc on did not take effect" , list .isEmpty () );
135101
102+ list = s .createQuery ( "from Human h inner join h.offspring o with o.mother.father = :cousin" )
103+ .setEntity ( "cousin" , s .load ( Human .class , Long .valueOf ( "123" ) ) )
104+ .list ();
105+ assertTrue ( "ad-hoc did take effect" , list .isEmpty () );
106+
136107 txn .commit ();
137108 s .close ();
138109
0 commit comments