HHH-3804 - Cleanup usage of deprecated APIs in testsuite (Session#find, etc)

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16536 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2009-05-11 21:13:36 +00:00
parent 6bde7fd4b1
commit 9d2b288c45
17 changed files with 1552 additions and 1291 deletions

View File

@ -23,6 +23,7 @@
<artifactId>maven-jdocbook-plugin</artifactId>
<version>2.1.2</version>
<extensions>true</extensions>
<executions>
<execution>
<!--
@ -36,6 +37,7 @@
</goals>
</execution>
</executions>
<!--
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
@ -44,6 +46,27 @@
<type>jdocbook-style</type>
</dependency>
</dependencies>
-->
<dependencies>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-docbook-xslt</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-jdocbook-style</artifactId>
<version>1.1.0</version>
<type>jdocbook-style</type>
</dependency>
<dependency>
<groupId>org.jboss.tools</groupId>
<artifactId>jbosstools-docbook-xslt</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<sourceDocumentName>Hibernate_Reference.xml</sourceDocumentName>
<masterTranslation>en-US</masterTranslation>

View File

@ -73,7 +73,7 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
Session s = openSession();
Transaction t = s.beginTransaction();
Iterator iter = s.iterate("select max(s.count) from Simple s");
Iterator iter = s.createQuery( "select max(s.count) from Simple s" ).iterate();
if ( getDialect() instanceof MySQLDialect ) assertTrue( iter.hasNext() && iter.next()==null );
@ -86,20 +86,20 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
// Test to make sure allocating an specified object operates correctly.
assertTrue(
s.find("select new org.hibernate.test.legacy.S(s.count, s.address) from Simple s").size() == 1
s.createQuery( "select new org.hibernate.test.legacy.S(s.count, s.address) from Simple s" ).list().size() == 1
);
// Quick check the base dialect functions operate correctly
assertTrue(
s.find("select max(s.count) from Simple s").size() == 1
s.createQuery( "select max(s.count) from Simple s" ).list().size() == 1
);
assertTrue(
s.find("select count(*) from Simple s").size() == 1
s.createQuery( "select count(*) from Simple s" ).list().size() == 1
);
if ( getDialect() instanceof Cache71Dialect) {
// Check Oracle Dialect mix of dialect functions - no args (no parenthesis and single arg functions
java.util.List rset = s.find("select s.name, sysdate, floor(s.pay), round(s.pay,0) from Simple s");
List rset = s.createQuery( "select s.name, sysdate, floor(s.pay), round(s.pay,0) from Simple s" ).list();
assertNotNull("Name string should have been returned",(((Object[])rset.get(0))[0]));
assertNotNull("Todays Date should have been returned",(((Object[])rset.get(0))[1]));
assertEquals("floor(45.8) result was incorrect ", new Integer(45), ( (Object[]) rset.get(0) )[2] );
@ -109,12 +109,12 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
s.update(simple);
// Test type conversions while using nested functions (Float to Int).
rset = s.find("select abs(round(s.pay,0)) from Simple s");
rset = s.createQuery( "select abs(round(s.pay,0)) from Simple s" ).list();
assertEquals("abs(round(-45.8)) result was incorrect ", new Float(46), rset.get(0));
// Test a larger depth 3 function example - Not a useful combo other than for testing
assertTrue(
s.find("select floor(round(sysdate,1)) from Simple s").size() == 1
s.createQuery( "select floor(round(sysdate,1)) from Simple s" ).list().size() == 1
);
// Test the oracle standard NVL funtion as a test of multi-param functions...
@ -126,7 +126,9 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
if ( (getDialect() instanceof Cache71Dialect) ) {
// Test the hsql standard MOD funtion as a test of multi-param functions...
Double value = (Double) s.find("select MOD(s.count, 2) from Simple as s where s.id = 10" ).get(0);
Double value = (Double) s.createQuery( "select MOD(s.count, 2) from Simple as s where s.id = 10" )
.list()
.get(0);
assertTrue( 0 == value.intValue() );
}
@ -349,22 +351,25 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
s.save(simple, new Long(10) );
if ( getDialect() instanceof Cache71Dialect) {
s.find("from Simple s where repeat('foo', 3) = 'foofoofoo'");
s.find("from Simple s where repeat(s.name, 3) = 'foofoofoo'");
s.find("from Simple s where repeat( lower(s.name), (3 + (1-1)) / 2) = 'foofoofoo'");
s.createQuery( "from Simple s where repeat('foo', 3) = 'foofoofoo'" ).list();
s.createQuery( "from Simple s where repeat(s.name, 3) = 'foofoofoo'" ).list();
s.createQuery( "from Simple s where repeat( lower(s.name), (3 + (1-1)) / 2) = 'foofoofoo'" ).list();
}
assertTrue(
s.find("from Simple s where upper( s.name ) ='SIMPLE 1'").size()==1
s.createQuery( "from Simple s where upper( s.name ) ='SIMPLE 1'" ).list().size()==1
);
if ( !(getDialect() instanceof HSQLDialect) ) {
assertTrue(
s.find("from Simple s where not( upper( s.name ) ='yada' or 1=2 or 'foo'='bar' or not('foo'='foo') or 'foo' like 'bar' )").size()==1
s.createQuery(
"from Simple s where not( upper( s.name ) ='yada' or 1=2 or 'foo'='bar' or not('foo'='foo') or 'foo' like 'bar' )"
).list()
.size()==1
);
}
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SybaseDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof InterbaseDialect) && !(getDialect() instanceof TimesTenDialect) ) { //My SQL has a funny concatenation operator
assertTrue(
s.find("from Simple s where lower( s.name || ' foo' ) ='simple 1 foo'").size()==1
s.createQuery( "from Simple s where lower( s.name || ' foo' ) ='simple 1 foo'" ).list().size()==1
);
}
/* + is not concat in Cache
@ -376,7 +381,7 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
*/
if ( (getDialect() instanceof Cache71Dialect) ) {
assertTrue(
s.find("from Simple s where lower( concat(s.name, ' foo') ) ='simple 1 foo'").size()==1
s.createQuery( "from Simple s where lower( concat(s.name, ' foo') ) ='simple 1 foo'" ).list().size()==1
);
}
@ -387,44 +392,61 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
s.save( other, new Long(20) );
//s.find("from Simple s where s.name ## 'cat|rat|bag'");
assertTrue(
s.find("from Simple s where upper( s.other.name ) ='SIMPLE 2'").size()==1
s.createQuery( "from Simple s where upper( s.other.name ) ='SIMPLE 2'" ).list().size()==1
);
assertTrue(
s.find("from Simple s where not ( upper( s.other.name ) ='SIMPLE 2' )").size()==0
s.createQuery( "from Simple s where not ( upper( s.other.name ) ='SIMPLE 2' )" ).list().size()==0
);
assertTrue(
s.find("select distinct s from Simple s where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2").size()==1
s.createQuery(
"select distinct s from Simple s where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2"
).list()
.size()==1
);
assertTrue(
s.find("select s from Simple s where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2 order by s.other.count").size()==1
s.createQuery(
"select s from Simple s where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2 order by s.other.count"
).list()
.size()==1
);
Simple min = new Simple();
min.setCount(-1);
s.save(min, new Long(30) );
if ( ! (getDialect() instanceof MySQLDialect) && ! (getDialect() instanceof HSQLDialect) ) { //My SQL has no subqueries
assertTrue(
s.find("from Simple s where s.count > ( select min(sim.count) from Simple sim )").size()==2
s.createQuery( "from Simple s where s.count > ( select min(sim.count) from Simple sim )" )
.list()
.size()==2
);
t.commit();
t = s.beginTransaction();
assertTrue(
s.find("from Simple s where s = some( select sim from Simple sim where sim.count>=0 ) and s.count >= 0").size()==2
s.createQuery(
"from Simple s where s = some( select sim from Simple sim where sim.count>=0 ) and s.count >= 0"
).list()
.size()==2
);
assertTrue(
s.find("from Simple s where s = some( select sim from Simple sim where sim.other.count=s.other.count ) and s.other.count > 0").size()==1
s.createQuery(
"from Simple s where s = some( select sim from Simple sim where sim.other.count=s.other.count ) and s.other.count > 0"
).list()
.size()==1
);
}
Iterator iter = s.iterate("select sum(s.count) from Simple s group by s.count having sum(s.count) > 10");
Iterator iter = s.createQuery( "select sum(s.count) from Simple s group by s.count having sum(s.count) > 10" )
.iterate();
assertTrue( iter.hasNext() );
assertEquals( new Long(12), iter.next() );
assertTrue( !iter.hasNext() );
if ( ! (getDialect() instanceof MySQLDialect) ) {
iter = s.iterate("select s.count from Simple s group by s.count having s.count = 12");
iter = s.createQuery( "select s.count from Simple s group by s.count having s.count = 12" ).iterate();
assertTrue( iter.hasNext() );
}
s.iterate("select s.id, s.count, count(t), max(t.date) from Simple s, Simple t where s.count = t.count group by s.id, s.count order by s.count");
s.createQuery(
"select s.id, s.count, count(t), max(t.date) from Simple s, Simple t where s.count = t.count group by s.id, s.count order by s.count"
).iterate();
Query q = s.createQuery("from Simple s");
q.setMaxResults(10);
@ -486,6 +508,7 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
public void testBlobClob() throws Exception {
Session s = openSession();
s.beginTransaction();
Blobber b = new Blobber();
b.setBlob( Hibernate.createBlob( "foo/bar/baz".getBytes() ) );
b.setClob( Hibernate.createClob("foo/bar/baz") );
@ -499,10 +522,11 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
b.getClob().getSubString(2, 3);
//b.getClob().setString(2, "abc");
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
Blobber b2 = new Blobber();
s.save(b2);
@ -512,22 +536,24 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
b.getClob().getSubString(1, 6);
//b.getClob().setString(1, "qwerty");
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
b.setClob( Hibernate.createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb") );
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
assertTrue( b.getClob().getSubString(1, 7).equals("xcvfxvc") );
//b.getClob().setString(5, "1234567890");
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
@ -580,7 +606,7 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
s = openSession();
t = s.beginTransaction();
List result = s.find(query);
List result = s.createQuery( query ).list();
assertTrue( result.size() == 1 );
assertTrue(result.get(0) instanceof Simple);
s.delete( result.get(0) );
@ -704,29 +730,60 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
assertTrue( test.getDate1().equals(testvalue));
test = (TestInterSystemsFunctionsClass) s.get(TestInterSystemsFunctionsClass.class, new Long(10), LockMode.UPGRADE);
assertTrue( test.getDate1().equals(testvalue));
Date value = (Date) s.find("select nvl(o.date,o.dateText) from TestInterSystemsFunctionsClass as o" ).get(0);
Date value = (Date) s.createQuery( "select nvl(o.date,o.dateText) from TestInterSystemsFunctionsClass as o" )
.list()
.get(0);
assertTrue( value.equals(testvalue));
Object nv = s.find("select nullif(o.dateText,o.dateText) from TestInterSystemsFunctionsClass as o" ).get(0);
Object nv = s.createQuery( "select nullif(o.dateText,o.dateText) from TestInterSystemsFunctionsClass as o" )
.list()
.get(0);
assertTrue( nv == null);
String dateText = (String) s.find("select nvl(o.dateText,o.date) from TestInterSystemsFunctionsClass as o" ).get(0);
String dateText = (String) s.createQuery(
"select nvl(o.dateText,o.date) from TestInterSystemsFunctionsClass as o"
).list()
.get(0);
assertTrue( dateText.equals("1977-07-03"));
value = (Date) s.find("select ifnull(o.date,o.date1) from TestInterSystemsFunctionsClass as o" ).get(0);
value = (Date) s.createQuery( "select ifnull(o.date,o.date1) from TestInterSystemsFunctionsClass as o" )
.list()
.get(0);
assertTrue( value.equals(testvalue));
value = (Date) s.find("select ifnull(o.date3,o.date,o.date1) from TestInterSystemsFunctionsClass as o" ).get(0);
value = (Date) s.createQuery( "select ifnull(o.date3,o.date,o.date1) from TestInterSystemsFunctionsClass as o" )
.list()
.get(0);
assertTrue( value.equals(testvalue));
Integer pos = (Integer) s.find("select position('07', o.dateText) from TestInterSystemsFunctionsClass as o" ).get(0);
Integer pos = (Integer) s.createQuery(
"select position('07', o.dateText) from TestInterSystemsFunctionsClass as o"
).list()
.get(0);
assertTrue(pos.intValue() == 6);
String st = (String) s.find("select convert(o.date1, SQL_TIME) from TestInterSystemsFunctionsClass as o" ).get(0);
String st = (String) s.createQuery( "select convert(o.date1, SQL_TIME) from TestInterSystemsFunctionsClass as o" )
.list()
.get(0);
assertTrue( st.equals("00:00:00"));
java.sql.Time tm = (java.sql.Time) s.find("select cast(o.date1, time) from TestInterSystemsFunctionsClass as o" ).get(0);
java.sql.Time tm = (java.sql.Time) s.createQuery(
"select cast(o.date1, time) from TestInterSystemsFunctionsClass as o"
).list()
.get(0);
assertTrue( tm.toString().equals("00:00:00"));
Double diff = (Double)s.find("select timestampdiff(SQL_TSI_FRAC_SECOND, o.date3, o.date1) from TestInterSystemsFunctionsClass as o" ).get(0);
Double diff = (Double) s.createQuery(
"select timestampdiff(SQL_TSI_FRAC_SECOND, o.date3, o.date1) from TestInterSystemsFunctionsClass as o"
).list()
.get(0);
assertTrue(diff.doubleValue() != 0.0);
diff = (Double)s.find("select timestampdiff(SQL_TSI_MONTH, o.date3, o.date1) from TestInterSystemsFunctionsClass as o" ).get(0);
diff = (Double) s.createQuery(
"select timestampdiff(SQL_TSI_MONTH, o.date3, o.date1) from TestInterSystemsFunctionsClass as o"
).list()
.get(0);
assertTrue(diff.doubleValue() == 16.0);
diff = (Double)s.find("select timestampdiff(SQL_TSI_WEEK, o.date3, o.date1) from TestInterSystemsFunctionsClass as o" ).get(0);
diff = (Double) s.createQuery(
"select timestampdiff(SQL_TSI_WEEK, o.date3, o.date1) from TestInterSystemsFunctionsClass as o"
).list()
.get(0);
assertTrue(diff.doubleValue() >= 16*4);
diff = (Double)s.find("select timestampdiff(SQL_TSI_YEAR, o.date3, o.date1) from TestInterSystemsFunctionsClass as o" ).get(0);
diff = (Double) s.createQuery(
"select timestampdiff(SQL_TSI_YEAR, o.date3, o.date1) from TestInterSystemsFunctionsClass as o"
).list()
.get(0);
assertTrue(diff.doubleValue() == 1.0);
t.commit();

View File

@ -270,7 +270,7 @@ public class DynamicFilterTest extends FunctionalTestCase {
session.enableFilter("region").setParameter("region", "APAC");
DetachedCriteria lineItemSubquery = DetachedCriteria.forClass(LineItem.class)
.add(Restrictions.ge("quantity", 1L))
.add(Restrictions.ge( "quantity", new Long(1L) ))
.createCriteria("product")
.add(Restrictions.eq("name", "Acme Hair Gel"))
.setProjection(Property.forName("id"));
@ -291,7 +291,7 @@ public class DynamicFilterTest extends FunctionalTestCase {
.setProjection(Property.forName("id"));
lineItemSubquery = DetachedCriteria.forClass(LineItem.class)
.add(Restrictions.ge("quantity", 1L))
.add(Restrictions.ge("quantity", new Long(1L) ))
.createCriteria("product")
.add(Subqueries.propertyIn("id", productSubquery))
.setProjection(Property.forName("id"));

View File

@ -1638,7 +1638,9 @@ public class ASTParserLoadingTest extends FunctionalTestCase {
assertTrue( "Incorrect return type", obj instanceof List );
assertEquals( "Incorrect return type", ( (List) obj ).size(), 2 );
iter = ((org.hibernate.classic.Session)session).iterate( "select new list(an.description, an.bodyWeight) from Animal an" );
iter = ( ( org.hibernate.classic.Session ) session ).createQuery(
"select new list(an.description, an.bodyWeight) from Animal an"
).iterate();
assertTrue( "Incorrect result size", iter.hasNext() );
obj = iter.next();
assertTrue( "Incorrect return type", obj instanceof List );

View File

@ -55,7 +55,7 @@ public class ABCProxyTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
List list = s.find("from B");
List list = s.createQuery( "from B" ).list();
assertTrue( list.size()==2 );
t.commit();
s.close();
@ -200,8 +200,8 @@ public class ABCProxyTest extends LegacyTestCase {
t = s.beginTransaction();
s.save( new B() );
s.save( new A() );
assertTrue( s.find("from B").size()==1 );
assertTrue( s.find("from A").size()==2 );
assertTrue( s.createQuery( "from B" ).list().size()==1 );
assertTrue( s.createQuery( "from A" ).list().size()==2 );
s.delete("from A");
t.commit();
s.close();
@ -253,14 +253,14 @@ public class ABCProxyTest extends LegacyTestCase {
t = s.beginTransaction();
List l = s.find( "from E e, A a where e.reverse = a.forward and a = ?", a, Hibernate.entity(A.class) );
assertTrue( l.size()==1 );
l = s.find( "from E e join fetch e.reverse" );
l = s.createQuery( "from E e join fetch e.reverse" ).list();
assertTrue( l.size()==2 );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
l = s.find( "from E e" );
l = s.createQuery( "from E e" ).list();
assertTrue( l.size()==2 );
E e = (E) l.get(0);
assertTrue( e==e.getReverse().getForward() );
@ -283,7 +283,7 @@ public class ABCProxyTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
l = s.find( "from E e" );
l = s.createQuery( "from E e" ).list();
assertTrue( l.size()==0 );
t.commit();
s.close();

View File

@ -42,7 +42,7 @@ public class ABCTest extends LegacyTestCase {
s.clear();
getSessions().evict(D.class);
getSessions().evict(A.class);
assertTrue( s.find("from D d join d.reverse r join d.inverse i where i = r").size()==1 );
assertTrue( s.createQuery( "from D d join d.reverse r join d.inverse i where i = r" ).list().size()==1 );
t.commit();
s.close();
}
@ -75,7 +75,7 @@ public class ABCTest extends LegacyTestCase {
d.setId( c1.getId() );
s.save(d);
assertTrue( s.find("from C2 c where 1=1 or 1=1").size()==0 );
assertTrue( s.createQuery( "from C2 c where 1=1 or 1=1" ).list().size()==0 );
t.commit();
s.close();

View File

@ -163,7 +163,7 @@ public class CustomSQLTest extends LegacyTestCase {
p.setName("Max");
p.setLastName("Andersen");
p.setNationalID("110974XYZÅ");
p.setNationalID("110974XYZ<EFBFBD>");
p.setAddress("P. P. Street 8");
Session s = openSession();
@ -183,7 +183,7 @@ public class CustomSQLTest extends LegacyTestCase {
assertEquals(p2.getLastName(),p.getLastName());
s.flush();
List list = s.find("select p from Party as p");
List list = s.createQuery( "select p from Party as p" ).list();
assertTrue(list.size() == 1);
s.connection().commit();
@ -191,17 +191,17 @@ public class CustomSQLTest extends LegacyTestCase {
s = openSession();
list = s.find("select p from Person as p where p.address = 'Lærkevænget 1'");
list = s.createQuery( "select p from Person as p where p.address = 'L<>rkev<65>nget 1'" ).list();
assertTrue(list.size() == 0);
p.setAddress("Lærkevænget 1");
p.setAddress("L<EFBFBD>rkev<EFBFBD>nget 1");
s.update(p);
list = s.find("select p from Person as p where p.address = 'Lærkevænget 1'");
list = s.createQuery( "select p from Person as p where p.address = 'L<>rkev<65>nget 1'" ).list();
assertTrue(list.size() == 1);
list = s.find("select p from Party as p where p.address = 'P. P. Street 8'");
list = s.createQuery( "select p from Party as p where p.address = 'P. P. Street 8'" ).list();
assertTrue(list.size() == 0);
s.delete(p);
list = s.find("select p from Person as p");
list = s.createQuery( "select p from Person as p" ).list();
assertTrue(list.size() == 0);
s.connection().commit();

View File

@ -95,6 +95,7 @@ public class FumTest extends LegacyTestCase {
public void testCriteriaCollection() throws Exception {
Session s = openSession();
s.beginTransaction();
Fum fum = new Fum( fumKey("fum") );
fum.setFum("a value");
fum.getMapComponent().getFummap().put("self", fum);
@ -102,10 +103,11 @@ public class FumTest extends LegacyTestCase {
fum.getMapComponent().getStringmap().put("string2", "a notha staring");
fum.getMapComponent().setCount(1);
s.save(fum);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
Fum b = (Fum) s.createCriteria(Fum.class).add(
Restrictions.in("fum", new String[] { "a value", "no value" } )
)
@ -114,8 +116,7 @@ public class FumTest extends LegacyTestCase {
assertTrue( b.getMapComponent().getFummap().size()==1 );
assertTrue( b.getMapComponent().getStringmap().size()==2 );
s.delete(b);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
@ -166,7 +167,7 @@ public class FumTest extends LegacyTestCase {
base = s.createCriteria(Fum.class)
.add( Restrictions.like("fum", "f%") )
.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)
.setFetchMode("friends", FetchMode.EAGER);
.setFetchMode( "friends", FetchMode.JOIN );
base.createCriteria("fo", "fo")
.add( Restrictions.eq( "fum", fum.getFo().getFum() ) );
map = (Map) base.list().get(0);
@ -203,7 +204,9 @@ public class FumTest extends LegacyTestCase {
s.delete(fum);
s.delete( fum.getFo() );
Iterator iter = fum.getFriends().iterator();
while ( iter.hasNext() ) s.delete( iter.next() );
while ( iter.hasNext() ) {
s.delete( iter.next() );
}
txn.commit();
s.close();
}
@ -226,7 +229,6 @@ public class FumTest extends LegacyTestCase {
}
public void testBeanResultTransformer() throws HibernateException, SQLException {
Session s = openSession();
Transaction transaction = s.beginTransaction();
Fum fum = new Fum( fumKey("fum") );
@ -271,7 +273,6 @@ public class FumTest extends LegacyTestCase {
s.flush();
transaction.commit();
s.close();
}
@ -284,9 +285,9 @@ public class FumTest extends LegacyTestCase {
fum = new Fum( fumKey("fi") );
fum.setFum("fee fi fo");
s.save(fum);
List list = s.find("select fum.id from Fum as fum where not fum.fum='FRIEND'");
List list = s.createQuery( "select fum.id from Fum as fum where not fum.fum='FRIEND'" ).list();
assertTrue( "list identifiers", list.size()==2);
Iterator iter = s.iterate("select fum.id from Fum fum where not fum.fum='FRIEND'");
Iterator iter = s.createQuery( "select fum.id from Fum fum where not fum.fum='FRIEND'" ).iterate();
int i=0;
while ( iter.hasNext() ) {
assertTrue( "iterate identifiers", iter.next() instanceof FumCompositeID);
@ -302,7 +303,6 @@ public class FumTest extends LegacyTestCase {
public FumCompositeID fumKey(String str) {
return fumKey(str,false);
}
@ -320,7 +320,7 @@ public class FumTest extends LegacyTestCase {
else {
id.setDate( new Date() );
}
id.setString( new String(str) );
id.setString( str );
if (aCompositeQueryTest) {
id.setShort( fumKeyShort++ );
@ -353,11 +353,11 @@ public class FumTest extends LegacyTestCase {
s.save(fum2);
assertTrue(
"find composite keyed objects",
s.find("from Fum fum where not fum.fum='FRIEND'").size()==2
s.createQuery( "from Fum fum where not fum.fum='FRIEND'" ).list().size()==2
);
assertTrue(
"find composite keyed object",
s.find("select fum from Fum fum where fum.fum='fee fi fo'").get(0)==fum
s.createQuery( "select fum from Fum fum where fum.fum='fee fi fo'" ).list().get(0)==fum
);
fum.setFo(null);
txn.commit();
@ -365,7 +365,7 @@ public class FumTest extends LegacyTestCase {
s = openSession();
txn = s.beginTransaction();
Iterator iter = s.iterate("from Fum fum where not fum.fum='FRIEND'");
Iterator iter = s.createQuery( "from Fum fum where not fum.fum='FRIEND'" ).iterate();
int i = 0;
while ( iter.hasNext() ) {
fum = (Fum) iter.next();
@ -401,6 +401,7 @@ public class FumTest extends LegacyTestCase {
public void testCompositeIDQuery() throws Exception {
Session s = openSession();
s.beginTransaction();
Fum fee = new Fum( fumKey("fee",true) );
fee.setFum("fee");
s.save(fee);
@ -414,38 +415,40 @@ public class FumTest extends LegacyTestCase {
Fum fum = new Fum( fumKey("fum",true) );
fum.setFum("fum");
s.save(fum);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
// Try to find the Fum object "fo" that we inserted searching by the string in the id
List vList = s.find("from Fum fum where fum.id.string='fo'" );
List vList = s.createQuery( "from Fum fum where fum.id.string='fo'" ).list();
assertTrue( "find by composite key query (find fo object)", vList.size() == 1 );
fum = (Fum)vList.get(0);
assertTrue( "find by composite key query (check fo object)", fum.getId().getString().equals("fo") );
// Try to find the Fum object "fi" that we inserted searching by the date in the id
vList = s.find("from Fum fum where fum.id.short = ?",new Short(fiShort),Hibernate.SHORT);
assertTrue( "find by composite key query (find fi object)", vList.size() == 1 );
vList = s.createQuery( "from Fum fum where fum.id.short = ?" )
.setParameter( 0, new Short(fiShort), Hibernate.SHORT )
.list();
assertEquals( "find by composite key query (find fi object)", 1, vList.size() );
fi = (Fum)vList.get(0);
assertTrue( "find by composite key query (check fi object)", fi.getId().getString().equals("fi") );
assertEquals( "find by composite key query (check fi object)", "fi", fi.getId().getString() );
// Make sure we can return all of the objects by searching by the date id
assertTrue(
"find by composite key query with arguments",
s.find("from Fum fum where fum.id.date <= ? and not fum.fum='FRIEND'",new Date(),Hibernate.DATE).size()==4
);
s.flush();
s.connection().commit();
vList = s.createQuery( "from Fum fum where fum.id.date <= ? and not fum.fum='FRIEND'" )
.setParameter( 0, new Date(), Hibernate.DATE )
.list();
assertEquals( "find by composite key query with arguments", 4, vList.size() );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
assertTrue(
s.iterate("select fum.id.short, fum.id.date, fum.id.string from Fum fum").hasNext()
s.createQuery( "select fum.id.short, fum.id.date, fum.id.string from Fum fum" ).iterate().hasNext()
);
assertTrue(
s.iterate("select fum.id from Fum fum").hasNext()
s.createQuery( "select fum.id from Fum fum" ).iterate().hasNext()
);
Query qu = s.createQuery("select fum.fum, fum , fum.fum, fum.id.date from Fum fum");
Type[] types = qu.getReturnTypes();
@ -466,34 +469,36 @@ public class FumTest extends LegacyTestCase {
assertTrue( "iterate on composite key", j==8 );
fum = (Fum) s.load( Fum.class, fum.getId() );
s.filter( fum.getQuxArray(), "where this.foo is null" );
s.filter( fum.getQuxArray(), "where this.foo.id = ?", "fooid", Hibernate.STRING );
s.createFilter( fum.getQuxArray(), "where this.foo is null" ).list();
s.createFilter( fum.getQuxArray(), "where this.foo.id = ?" )
.setParameter( 0, "fooid", Hibernate.STRING )
.list();
Query f = s.createFilter( fum.getQuxArray(), "where this.foo.id = :fooId" );
f.setString("fooId", "abc");
assertFalse( f.iterate().hasNext() );
iter = s.iterate("from Fum fum where not fum.fum='FRIEND'");
iter = s.createQuery( "from Fum fum where not fum.fum='FRIEND'" ).iterate();
int i = 0;
while ( iter.hasNext() ) {
fum = (Fum) iter.next();
//iter.remove();
s.delete(fum);
i++;
}
assertTrue( "iterate on composite key", i==4 );
s.flush();
s.iterate("from Fum fu, Fum fo where fu.fo.id.string = fo.id.string and fo.fum is not null");
s.createQuery( "from Fum fu, Fum fo where fu.fo.id.string = fo.id.string and fo.fum is not null" ).iterate();
s.find("from Fumm f1 inner join f1.fum f2");
s.createQuery( "from Fumm f1 inner join f1.fum f2" ).list();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
public void testCompositeIDCollections() throws Exception {
Session s = openSession();
s.beginTransaction();
Fum fum1 = new Fum( fumKey("fum1") );
Fum fum2 = new Fum( fumKey("fum2") );
fum1.setFum("fee fo fi");
@ -509,11 +514,11 @@ public class FumTest extends LegacyTestCase {
q.setFums(set);
q.setMoreFums(list);
fum1.setQuxArray( new Qux[] {q} );
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
q = (Qux) s.load( Qux.class, q.getKey() );
assertTrue( "collection of fums", q.getFums().size()==2 );
assertTrue( "collection of fums", q.getMoreFums().size()==1 );
@ -526,14 +531,14 @@ public class FumTest extends LegacyTestCase {
f = (Fum) iter.next();
s.delete(f);
s.delete(q);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
public void testDeleteOwner() throws Exception {
Session s = openSession();
s.beginTransaction();
Qux q = new Qux();
s.save(q);
Fum f1 = new Fum( fumKey("f1") );
@ -550,20 +555,20 @@ public class FumTest extends LegacyTestCase {
q.setMoreFums(list);
s.save(f1);
s.save(f2);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
q = (Qux) s.load( Qux.class, q.getKey(), LockMode.UPGRADE );
s.lock( q, LockMode.UPGRADE );
s.delete(q);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
list = s.find("from Fum fum where not fum.fum='FRIEND'");
s.beginTransaction();
list = s.createQuery( "from Fum fum where not fum.fum='FRIEND'" ).list();
assertTrue( "deleted owner", list.size()==2 );
s.lock( list.get(0), LockMode.UPGRADE );
s.lock( list.get(1), LockMode.UPGRADE );
@ -571,14 +576,14 @@ public class FumTest extends LegacyTestCase {
while ( iter.hasNext() ) {
s.delete( iter.next() );
}
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
public void testCompositeIDs() throws Exception {
Session s = openSession();
s.beginTransaction();
Fo fo = Fo.newFo();
Properties props = new Properties();
props.setProperty("foo", "bar");
@ -588,11 +593,11 @@ public class FumTest extends LegacyTestCase {
s.save( fo, fumKey("an instance of fo") );
s.flush();
props.setProperty("x", "y");
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
fo = (Fo) s.load( Fo.class, fumKey("an instance of fo") );
props = (Properties) fo.getSerial();
assertTrue( props.getProperty("foo").equals("bar") );
@ -600,15 +605,15 @@ public class FumTest extends LegacyTestCase {
assertTrue( props.getProperty("x").equals("y") );
assertTrue( fo.getBuf()[0]=='a' );
fo.getBuf()[1]=(byte)126;
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
fo = (Fo) s.load( Fo.class, fumKey("an instance of fo") );
assertTrue( fo.getBuf()[1]==126 );
assertTrue(
s.iterate("from Fo fo where fo.id.string like 'an instance of fo'").next()==fo
s.createQuery( "from Fo fo where fo.id.string like 'an instance of fo'" ).iterate().next()==fo
);
s.delete(fo);
s.flush();
@ -619,12 +624,13 @@ public class FumTest extends LegacyTestCase {
catch (Exception e) {
//System.out.println( e.getMessage() );
}
s.connection().commit();
s.getTransaction().commit();
s.close();
}
public void testKeyManyToOne() throws Exception {
Session s = openSession();
s.beginTransaction();
Inner sup = new Inner();
InnerKey sid = new InnerKey();
sup.setDudu("dudu");
@ -647,75 +653,84 @@ public class FumTest extends LegacyTestCase {
s.save(sup);
s.save(m);
s.save(d);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
Inner in = (Inner) s.find("from Inner").get(0);
s.beginTransaction();
Inner in = (Inner) s.createQuery( "from Inner" ).list().get(0);
assertTrue( in.getMiddles().size()==1 );
s.flush();
s.connection().commit();
s.close();
s = openSession();
assertTrue( s.find("from Inner _inner join _inner.middles middle").size()==1 );
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
assertTrue( s.createQuery( "from Inner _inner join _inner.middles middle" ).list().size()==1 );
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
d = (Outer) s.load(Outer.class, did);
assertTrue( d.getId().getMaster().getId().getSup().getDudu().equals("dudu") );
s.delete(d);
s.delete( d.getId().getMaster() );
s.save( d.getId().getMaster() );
s.save(d);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
d = (Outer) s.find("from Outer o where o.id.detailId = ?", d.getId().getDetailId(), Hibernate.STRING ).get(0);
s.find("from Outer o where o.id.master.id.sup.dudu is not null");
s.find("from Outer o where o.id.master.id.sup.id.akey is not null");
s.find("from Inner i where i.backOut.id.master.id.sup.id.akey = i.id.bkey");
List l = s.find("select o.id.master.id.sup.dudu from Outer o where o.id.master.id.sup.dudu is not null");
s.beginTransaction();
d = (Outer) s.createQuery( "from Outer o where o.id.detailId = ?" )
.setParameter( 0, d.getId().getDetailId(), Hibernate.STRING )
.list()
.get(0);
s.createQuery( "from Outer o where o.id.master.id.sup.dudu is not null" ).list();
s.createQuery( "from Outer o where o.id.master.id.sup.id.akey is not null" ).list();
s.createQuery( "from Inner i where i.backOut.id.master.id.sup.id.akey = i.id.bkey" ).list();
List l = s.createQuery( "select o.id.master.id.sup.dudu from Outer o where o.id.master.id.sup.dudu is not null" )
.list();
assertTrue(l.size()==1);
l = s.find("select o.id.master.id.sup.id.akey from Outer o where o.id.master.id.sup.id.akey is not null");
l = s.createQuery( "select o.id.master.id.sup.id.akey from Outer o where o.id.master.id.sup.id.akey is not null" )
.list();
assertTrue(l.size()==1);
s.find("select i.backOut.id.master.id.sup.id.akey from Inner i where i.backOut.id.master.id.sup.id.akey = i.id.bkey");
s.find("from Outer o where o.id.master.bla = ''");
s.find("from Outer o where o.id.master.id.one = ''");
s.find("from Inner inn where inn.id.bkey is not null and inn.backOut.id.master.id.sup.id.akey > 'a'");
s.find("from Outer as o left join o.id.master m left join m.id.sup where o.bubu is not null");
s.find("from Outer as o left join o.id.master.id.sup s where o.bubu is not null");
s.find("from Outer as o left join o.id.master m left join o.id.master.id.sup s where o.bubu is not null");
s.createQuery(
"select i.backOut.id.master.id.sup.id.akey from Inner i where i.backOut.id.master.id.sup.id.akey = i.id.bkey"
).list();
s.createQuery( "from Outer o where o.id.master.bla = ''" ).list();
s.createQuery( "from Outer o where o.id.master.id.one = ''" ).list();
s.createQuery( "from Inner inn where inn.id.bkey is not null and inn.backOut.id.master.id.sup.id.akey > 'a'" )
.list();
s.createQuery( "from Outer as o left join o.id.master m left join m.id.sup where o.bubu is not null" ).list();
s.createQuery( "from Outer as o left join o.id.master.id.sup s where o.bubu is not null" ).list();
s.createQuery( "from Outer as o left join o.id.master m left join o.id.master.id.sup s where o.bubu is not null" )
.list();
s.delete(d);
s.delete( d.getId().getMaster() );
s.delete( d.getId().getMaster().getId().getSup() );
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
public void testCompositeKeyPathExpressions() throws Exception {
Session s = openSession();
s.find("select fum1.fo from Fum fum1 where fum1.fo.fum is not null");
s.find("from Fum fum1 where fum1.fo.fum is not null order by fum1.fo.fum");
s.beginTransaction();
s.createQuery( "select fum1.fo from Fum fum1 where fum1.fo.fum is not null" ).list();
s.createQuery( "from Fum fum1 where fum1.fo.fum is not null order by fum1.fo.fum" ).list();
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof HSQLDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof PointbaseDialect) ) {
s.find("from Fum fum1 where exists elements(fum1.friends)");
s.createQuery( "from Fum fum1 where exists elements(fum1.friends)" ).list();
if(!(getDialect() instanceof TimesTenDialect)) { // can't execute because TimesTen can't do subqueries combined with aggreations
s.find("from Fum fum1 where size(fum1.friends) = 0");
s.createQuery( "from Fum fum1 where size(fum1.friends) = 0" ).list();
}
}
s.find("select elements(fum1.friends) from Fum fum1");
s.find("from Fum fum1, fr in elements( fum1.friends )");
s.connection().commit();
s.createQuery( "select elements(fum1.friends) from Fum fum1" ).list();
s.createQuery( "from Fum fum1, fr in elements( fum1.friends )" ).list();
s.getTransaction().commit();
s.close();
}
public void testUnflushedSessionSerialization() throws Exception {
///////////////////////////////////////////////////////////////////////////
// Test insertions across serializations
Session s = getSessions().openSession();

View File

@ -70,11 +70,11 @@ public class IJ2Test extends LegacyTestCase {
getSessions().evict(I.class);
s = getSessions().openSession();
assertTrue( s.find("from I").size()==2 );
assertTrue( s.find("from J").size()==1 );
assertTrue( s.find("from J j where j.amount > 0 and j.name is not null").size()==1 );
assertTrue( s.find("from I i where i.class = org.hibernate.test.legacy.I").size()==1 );
assertTrue( s.find("from I i where i.class = J").size()==1 );
assertTrue( s.createQuery( "from I" ).list().size()==2 );
assertTrue( s.createQuery( "from J" ).list().size()==1 );
assertTrue( s.createQuery( "from J j where j.amount > 0 and j.name is not null" ).list().size()==1 );
assertTrue( s.createQuery( "from I i where i.class = org.hibernate.test.legacy.I" ).list().size()==1 );
assertTrue( s.createQuery( "from I i where i.class = J" ).list().size()==1 );
s.connection().commit();
s.close();
@ -108,9 +108,9 @@ public class IJ2Test extends LegacyTestCase {
getSessions().evict(I.class);
s = getSessions().openSession();
assertTrue( s.find("from K k inner join k.is i where i.name = 'j'").size()==1 );
assertTrue( s.find("from K k inner join k.is i where i.name = 'i'").size()==1 );
assertTrue( s.find("from K k left join fetch k.is").size()==2 );
assertTrue( s.createQuery( "from K k inner join k.is i where i.name = 'j'" ).list().size()==1 );
assertTrue( s.createQuery( "from K k inner join k.is i where i.name = 'i'" ).list().size()==1 );
assertTrue( s.createQuery( "from K k left join fetch k.is" ).list().size()==2 );
s.connection().commit();
s.close();

View File

@ -63,10 +63,10 @@ public class IJTest extends LegacyTestCase {
s.close();
s = getSessions().openSession();
assertTrue( s.find("from I").size()==2 );
assertTrue( s.find("from J").size()==1 );
assertTrue( s.find("from I i where i.class = 0").size()==1 );
assertTrue( s.find("from I i where i.class = 1").size()==1 );
assertTrue( s.createQuery( "from I" ).list().size()==2 );
assertTrue( s.createQuery( "from J" ).list().size()==1 );
assertTrue( s.createQuery( "from I i where i.class = 0" ).list().size()==1 );
assertTrue( s.createQuery( "from I i where i.class = 1" ).list().size()==1 );
s.connection().commit();
s.close();

View File

@ -1,11 +1,16 @@
package org.hibernate.test.legacy;
import java.util.Iterator;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
import org.hibernate.util.StringHelper;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.dialect.Dialect;
import org.hibernate.classic.Session;
import org.hibernate.type.Type;
import org.hibernate.Query;
/**
* @author Steve Ebersole
@ -54,4 +59,34 @@ public abstract class LegacyTestCase extends FunctionalTestCase {
}
}
}
protected int doDelete(Session session, String queryString) {
return doDelete( session, session.createQuery( queryString ) );
}
protected int doDelete(Session session, String queryString, Object param, Type paramType) {
Query query = session.createQuery( queryString )
.setParameter( 0, param, paramType );
return doDelete( session, query );
}
protected int doDelete(Session session, String queryString, Object[] params, Type[] paramTypes) {
Query query = session.createQuery( queryString );
if ( params != null ) {
for ( int i = 0; i < params.length; i++ ) {
query.setParameter( i, params[i], paramTypes[i] );
}
}
return doDelete( session, query );
}
protected int doDelete(Session session, Query selectQuery) {
int count = 0;
Iterator itr = selectQuery.list().iterator();
while ( itr.hasNext() ) {
session.delete( itr.next() );
count++;
}
return count;
}
}

View File

@ -166,11 +166,11 @@ public class MasterDetailTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
List list = s.find("from Up up order by up.id2 asc");
List list = s.createQuery( "from Up up order by up.id2 asc" ).list();
assertTrue( list.size()==2 );
assertFalse( list.get(0) instanceof Down );
assertTrue( list.get(1) instanceof Down );
list = s.find("from Down down");
list = s.createQuery( "from Down down" ).list();
assertTrue( list.size()==1 );
assertTrue( list.get(0) instanceof Down );
//list = s.find("from Up down where down.class = Down");
@ -195,7 +195,7 @@ public class MasterDetailTest extends LegacyTestCase {
s.close();
s = openSession();
t = s.beginTransaction();
Iterator i = s.iterate("from Master");
Iterator i = s.createQuery( "from Master" ).iterate();
m = (Master) i.next();
assertTrue( m.getOtherMaster()==m );
if (getDialect() instanceof HSQLDialect) { m.setOtherMaster(null); s.flush(); }
@ -273,7 +273,7 @@ public class MasterDetailTest extends LegacyTestCase {
s.close();
s = openSession();
t = s.beginTransaction();
s.find("from Several");
s.createQuery( "from Several" ).list();
t.commit();
s.close();
s = openSession();
@ -287,12 +287,12 @@ public class MasterDetailTest extends LegacyTestCase {
Session s = openSession();
Transaction t = s.beginTransaction();
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) ) {
s.iterate("FROM Master m WHERE NOT EXISTS ( FROM m.details d WHERE NOT d.i=5 )");
s.iterate("FROM Master m WHERE NOT 5 IN ( SELECT d.i FROM m.details AS d )");
s.createQuery( "FROM Master m WHERE NOT EXISTS ( FROM m.details d WHERE NOT d.i=5 )" ).iterate();
s.createQuery( "FROM Master m WHERE NOT 5 IN ( SELECT d.i FROM m.details AS d )" ).iterate();
}
s.iterate("SELECT m FROM Master m JOIN m.details d WHERE d.i=5");
s.find("SELECT m FROM Master m JOIN m.details d WHERE d.i=5");
s.find("SELECT m.id FROM Master AS m JOIN m.details AS d WHERE d.i=5");
s.createQuery( "SELECT m FROM Master m JOIN m.details d WHERE d.i=5" ).iterate();
s.createQuery( "SELECT m FROM Master m JOIN m.details d WHERE d.i=5" ).list();
s.createQuery( "SELECT m.id FROM Master AS m JOIN m.details AS d WHERE d.i=5" ).list();
t.commit();
s.close();
}
@ -318,7 +318,9 @@ public class MasterDetailTest extends LegacyTestCase {
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof org.hibernate.dialect.TimesTenDialect)) {
assertTrue(
"query",
s.find("from Detail d, Master m where m = d.master and size(m.outgoing) = 0 and size(m.incoming) = 0").size()==2
s.createQuery(
"from Detail d, Master m where m = d.master and size(m.outgoing) = 0 and size(m.incoming) = 0"
).list().size()==2
);
}
t.commit();
@ -348,17 +350,17 @@ public class MasterDetailTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
assertTrue( s.find("select elements(master.details) from Master master").size()==2 );
assertTrue( s.createQuery( "select elements(master.details) from Master master" ).list().size()==2 );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
List list = s.find("from Master m left join fetch m.details");
List list = s.createQuery( "from Master m left join fetch m.details" ).list();
Master m = (Master) list.get(0);
assertTrue( Hibernate.isInitialized( m.getDetails() ) );
assertTrue( m.getDetails().size()==2 );
list = s.find("from Detail d inner join fetch d.master");
list = s.createQuery( "from Detail d inner join fetch d.master" ).list();
Detail dt = (Detail) list.get(0);
Serializable dtid = s.getIdentifier(dt);
assertTrue( dt.getMaster()==m );
@ -370,7 +372,8 @@ public class MasterDetailTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
list = s.find("select m from Master m1, Master m left join fetch m.details where m.name=m1.name");
list = s.createQuery( "select m from Master m1, Master m left join fetch m.details where m.name=m1.name" )
.list();
assertTrue( Hibernate.isInitialized( ( (Master) list.get(0) ).getDetails() ) );
dt = (Detail) s.load(Detail.class, dtid);
assertTrue( ( (Master) list.get(0) ).getDetails().contains(dt) );
@ -379,7 +382,9 @@ public class MasterDetailTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
list = s.find("select m, m1.name from Master m1, Master m left join fetch m.details where m.name=m1.name");
list = s.createQuery(
"select m, m1.name from Master m1, Master m left join fetch m.details where m.name=m1.name"
).list();
assertTrue( Hibernate.isInitialized( ( (Master) ( (Object[]) list.get(0) )[0] ).getDetails() ) );
dt = (Detail) s.load(Detail.class, dtid);
assertTrue( ( (Master) ( (Object[]) list.get(0) )[0] ).getDetails().contains(dt) );
@ -395,8 +400,8 @@ public class MasterDetailTest extends LegacyTestCase {
Detail dd = (Detail) s.load(Detail.class, did);
master = dd.getMaster();
assertTrue( "detail-master", master.getDetails().contains(dd) );
assertTrue( s.filter( master.getDetails(), "order by this.i desc").size()==2 );
assertTrue( s.filter( master.getDetails(), "select this where this.id > -1").size()==2 );
assertTrue( s.createFilter( master.getDetails(), "order by this.i desc" ).list().size()==2 );
assertTrue( s.createFilter( master.getDetails(), "select this where this.id > -1" ).list().size()==2 );
Query q = s.createFilter( master.getDetails(), "where this.id > :id" );
q.setInteger("id", -1);
assertTrue( q.list().size()==2 );
@ -413,18 +418,21 @@ public class MasterDetailTest extends LegacyTestCase {
q.setParameterList("ids", list);
assertTrue( q.list().size()==1 );
assertTrue( q.iterate().hasNext() );
assertTrue( s.filter( master.getDetails(), "where this.id > -1").size()==2 );
assertTrue( s.filter( master.getDetails(), "select this.master where this.id > -1").size()==2 );
assertTrue( s.filter( master.getDetails(), "select m from Master m where this.id > -1 and this.master=m").size()==2 );
assertTrue( s.filter( master.getIncoming(), "where this.id > -1 and this.name is not null").size()==0 );
assertTrue( s.createFilter( master.getDetails(), "where this.id > -1" ).list().size()==2 );
assertTrue( s.createFilter( master.getDetails(), "select this.master where this.id > -1" ).list().size()==2 );
assertTrue(
s.createFilter( master.getDetails(), "select m from Master m where this.id > -1 and this.master=m" )
.list()
.size()==2 );
assertTrue( s.createFilter( master.getIncoming(), "where this.id > -1 and this.name is not null" ).list().size()==0 );
assertTrue( s.createFilter( master.getDetails(), "select max(this.i)" ).iterate().next() instanceof Integer );
assertTrue( s.createFilter( master.getDetails(), "select max(this.i) group by this.id" ).iterate().next() instanceof Integer );
assertTrue( s.createFilter( master.getDetails(), "select count(*)" ).iterate().next() instanceof Long );
assertTrue( s.createFilter( master.getDetails(), "select this.master" ).list().size()==2 );
assertTrue( s.filter( master.getMoreDetails(), "" ).size()==0 );
assertTrue( s.filter( master.getIncoming(), "" ).size()==0 );
assertTrue( s.createFilter( master.getMoreDetails(), "" ).list().size()==0 );
assertTrue( s.createFilter( master.getIncoming(), "" ).list().size()==0 );
Query f = s.createFilter( master.getDetails(), "select max(this.i) where this.i < :top and this.i>=:bottom" );
f.setInteger("top", 100);
@ -474,7 +482,7 @@ public class MasterDetailTest extends LegacyTestCase {
master1.addIncoming(master3);
master3.addOutgoing(master1);
Serializable m1id = s.getIdentifier(master1);
assertTrue( s.filter( master1.getIncoming(), "where this.id > 0 and this.name is not null").size()==2 );
assertTrue( s.createFilter( master1.getIncoming(), "where this.id > 0 and this.name is not null" ).list().size()==2 );
s.flush();
s.connection().commit();
s.close();
@ -596,8 +604,8 @@ public class MasterDetailTest extends LegacyTestCase {
m = (Master) s.load( Master.class, mid );
assertTrue( ( (Detail) m.getMoreDetails().iterator().next() ).getSubDetails().size()!=0 );
s.delete(m);
assertTrue( s.find("from SubDetail").size()==0 );
assertTrue( s.find("from Detail d").size()==0 );
assertTrue( s.createQuery( "from SubDetail" ).list().size()==0 );
assertTrue( s.createQuery( "from Detail d" ).list().size()==0 );
s.delete( s.load(Master.class, m0id) );
txn.commit();
s.close();
@ -796,7 +804,8 @@ public class MasterDetailTest extends LegacyTestCase {
assertTrue( list.get(1)!=null && list.get(0)==null );
assertTrue(
s.iterate("from Category c where c.name = org.hibernate.test.legacy.Category.ROOT_CATEGORY").hasNext()
s.createQuery( "from Category c where c.name = org.hibernate.test.legacy.Category.ROOT_CATEGORY" )
.iterate().hasNext()
);
s.delete(c);
s.flush();

View File

@ -55,45 +55,49 @@ public class MultiTableTest extends LegacyTestCase {
public void testFetchOneToMany() throws Exception {
Session s = openSession();
s.createCriteria(Po.class).setFetchMode("set", FetchMode.EAGER).list();
s.createCriteria(Po.class).setFetchMode("list", FetchMode.EAGER).list();
s.connection().commit();
s.beginTransaction();
s.createCriteria(Po.class).setFetchMode("set", FetchMode.JOIN).list();
s.createCriteria(Po.class).setFetchMode("list", FetchMode.JOIN).list();
s.getTransaction().commit();
s.close();
}
public void testNarrow() throws Exception {
Session s = openSession();
s.find("from Po po, Lower low where low.mypo = po");
s.find("from Po po join po.set as sm where sm.amount > 0");
s.find("from Po po join po.top as low where low.foo = 'po'");
s.connection().commit();
s.beginTransaction();
s.createQuery("from Po po, Lower low where low.mypo = po").list();
s.createQuery("from Po po join po.set as sm where sm.amount > 0").list();
s.createQuery("from Po po join po.top as low where low.foo = 'po'").list();
s.getTransaction().commit();
s.close();
}
public void testJoins() throws Exception {
Session s = openSession();
s.find("from Lower l join l.yetanother l2 where lower(l2.name) > 'a'");
s.find("from Lower l where lower(l.yetanother.top.name) > 'a'");
s.find("from SubMulti sm join sm.children smc where smc.name > 'a'");
s.find("select s, ya from Lower s join s.yetanother ya");
s.find("from Lower s1 join s1.bag s2");
s.find("from Lower s1 left join s1.bag s2");
s.find("select s, a from Lower s join s.another a");
s.find("select s, a from Lower s left join s.another a");
s.find("from Top s, Lower ls");
s.find("from Lower ls join ls.set s where s.name > 'a'");
s.find("from Po po join po.list sm where sm.name > 'a'");
s.find("from Lower ls inner join ls.another s where s.name is not null");
s.find("from Lower ls where ls.other.another.name is not null");
s.find("from Multi m where m.derived like 'F%'");
s.find("from SubMulti m where m.derived like 'F%'");
s.connection().commit();
s.beginTransaction();
s.createQuery( "from Lower l join l.yetanother l2 where lower(l2.name) > 'a'" ).list();
s.createQuery( "from Lower l where lower(l.yetanother.top.name) > 'a'" ).list();
s.createQuery( "from SubMulti sm join sm.children smc where smc.name > 'a'" ).list();
s.createQuery( "select s, ya from Lower s join s.yetanother ya" ).list();
s.createQuery( "from Lower s1 join s1.bag s2" ).list();
s.createQuery( "from Lower s1 left join s1.bag s2" ).list();
s.createQuery( "select s, a from Lower s join s.another a" ).list();
s.createQuery( "select s, a from Lower s left join s.another a" ).list();
s.createQuery( "from Top s, Lower ls" ).list();
s.createQuery( "from Lower ls join ls.set s where s.name > 'a'" ).list();
s.createQuery( "from Po po join po.list sm where sm.name > 'a'" ).list();
s.createQuery( "from Lower ls inner join ls.another s where s.name is not null" ).list();
s.createQuery( "from Lower ls where ls.other.another.name is not null" ).list();
s.createQuery( "from Multi m where m.derived like 'F%'" ).list();
s.createQuery( "from SubMulti m where m.derived like 'F%'" ).list();
s.getTransaction().commit();
s.close();
}
public void testSubclassCollection() throws Exception {
//if ( getDialect() instanceof HSQLDialect ) return; //TODO: figure out why!?
Session s = openSession();
s.beginTransaction();
SubMulti sm = new SubMulti();
SubMulti sm1 = new SubMulti();
SubMulti sm2 = new SubMulti();
@ -111,37 +115,45 @@ public class MultiTableTest extends LegacyTestCase {
Serializable id = s.save(sm);
s.save(sm1);
s.save(sm2);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
getSessions().evict(SubMulti.class);
s = openSession();
s.beginTransaction();
s.connection().createStatement().executeQuery(
"select * from leafsubsubclass sm, nonleafsubclass m, rootclass s where sm.sid=m.sid and sm.sid=s.id1_ and sm.sid=1"
).next();
assertTrue( s.find("select s from SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null").size()==2 );
s.find("select c from SubMulti sm join sm.children c");
assertTrue( s.find("select elements(sm.children) from SubMulti as sm").size()==2 );
assertTrue( s.find("select distinct sm from SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null").size()==1 );
assertTrue(
s.createQuery(
"select s from SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null"
).list().size()==2 );
s.createQuery( "select c from SubMulti sm join sm.children c" ).list();
assertTrue( s.createQuery( "select elements(sm.children) from SubMulti as sm" ).list().size()==2 );
assertTrue(
s.createQuery(
"select distinct sm from SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null"
).list().size()==1 );
sm = (SubMulti) s.load(SubMulti.class, id);
assertTrue( sm.getChildren().size()==2 );
assertEquals(
s.filter( sm.getMoreChildren(), "select count(*) where this.amount>-1 and this.name is null" ).iterator().next(),
s.createFilter( sm.getMoreChildren(), "select count(*) where this.amount>-1 and this.name is null" ).list().get(0),
new Long(2)
);
assertEquals( "FOO", sm.getDerived() );
assertSame(
s.iterate("select distinct s from SubMulti s where s.moreChildren[1].amount < 1.0").next(),
s.createQuery( "select distinct s from SubMulti s where s.moreChildren[1].amount < 1.0" ).iterate().next(),
sm
);
assertTrue( sm.getMoreChildren().size()==2 );
s.delete(sm);
Iterator iter = sm.getChildren().iterator();
while ( iter.hasNext() ) s.delete( iter.next() );
while ( iter.hasNext() ) {
s.delete( iter.next() );
}
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
@ -166,26 +178,26 @@ public class MultiTableTest extends LegacyTestCase {
public void testQueries() throws Exception {
Session s = openSession();
s.beginTransaction();
Long id = ( Long ) s.save( new TrivialClass() );
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
TrivialClass tc = (TrivialClass) s.load(TrivialClass.class, id);
s.find("from TrivialClass s where s.id = 2");
s.find("select t.count from Top t");
s.find("from Lower s where s.another.name='name'");
s.find("from Lower s where s.yetanother.name='name'");
s.find("from Lower s where s.yetanother.name='name' and s.yetanother.foo is null");
s.find("from Top s where s.count=1");
s.find("select s.count from Top s, Lower ls where ls.another=s");
s.find("select elements(ls.bag), elements(ls.set) from Lower ls");
s.iterate("from Lower");
s.iterate("from Top");
s.createQuery( "from TrivialClass s where s.id = 2" ).list();
s.createQuery( "select t.count from Top t" ).list();
s.createQuery( "from Lower s where s.another.name='name'" ).list();
s.createQuery( "from Lower s where s.yetanother.name='name'" ).list();
s.createQuery( "from Lower s where s.yetanother.name='name' and s.yetanother.foo is null" ).list();
s.createQuery( "from Top s where s.count=1" ).list();
s.createQuery( "select s.count from Top s, Lower ls where ls.another=s" ).list();
s.createQuery( "select elements(ls.bag), elements(ls.set) from Lower ls" ).list();
s.createQuery( "from Lower" ).iterate();
s.createQuery( "from Top" ).iterate();
s.delete(tc);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
@ -197,9 +209,12 @@ public class MultiTableTest extends LegacyTestCase {
s.save( sm );
t.commit();
s.close();
s = openSession();
s.delete( "from SubMulti" );
// doDelete( s, "from SubMulti" );
// t = s.beginTransaction();
t = s.beginTransaction();
doDelete( s, "from SubMulti" );
t.commit();
s.close();
}
@ -263,7 +278,7 @@ public class MultiTableTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
Iterator iter = s.iterate("select\n\nt from Top t where t.count>0");
Iterator iter = s.createQuery( "select\n\nt from Top t where t.count>0" ).iterate();
boolean foundSimp = false;
boolean foundMulti = false;
boolean foundSubMulti = false;
@ -274,34 +289,35 @@ public class MultiTableTest extends LegacyTestCase {
if ( o instanceof SubMulti ) foundSubMulti = true;
}
assertTrue( foundSimp&&foundMulti&&foundSubMulti );
s.find("from Multi m where m.count>0 and m.extraProp is not null");
s.find("from Top m where m.count>0 and m.name is not null");
s.find("from Lower m where m.other is not null");
s.find("from Multi m where m.other.id = 1");
s.find("from SubMulti m where m.amount > 0.0");
s.createQuery( "from Multi m where m.count>0 and m.extraProp is not null" ).list();
s.createQuery( "from Top m where m.count>0 and m.name is not null" ).list();
s.createQuery( "from Lower m where m.other is not null" ).list();
s.createQuery( "from Multi m where m.other.id = 1" ).list();
s.createQuery( "from SubMulti m where m.amount > 0.0" ).list();
assertTrue(
s.find("from Multi").size()==2
s.createQuery( "from Multi" ).list().size()==2
);
assertTrue(
s.find("from Multi m where m.class = SubMulti").size()==1
s.createQuery( "from Multi m where m.class = SubMulti" ).list().size()==1
);
assertTrue(
s.find("from Top m where m.class = Multi").size()==1
s.createQuery( "from Top m where m.class = Multi" ).list().size()==1
);
assertTrue(
s.find("from Top").size()==3
s.createQuery( "from Top" ).list().size()==3
);
assertTrue(
s.find("from Lower").size()==0
s.createQuery( "from Lower" ).list().size()==0
);
assertTrue(
s.find("from SubMulti").size()==1
s.createQuery( "from SubMulti" ).list().size()==1
);
s.find("from Lower ls join ls.bag s where s.id is not null");
s.find("from Lower ls join ls.set s where s.id is not null");
if ( !(getDialect() instanceof MySQLDialect) ) s.find("from SubMulti sm where exists elements(sm.children)");
s.createQuery( "from Lower ls join ls.bag s where s.id is not null" ).list();
s.createQuery( "from Lower ls join ls.set s where s.id is not null" ).list();
if ( !(getDialect() instanceof MySQLDialect) )
s.createQuery( "from SubMulti sm where exists elements(sm.children)" ).list();
List l = s.createCriteria(Top.class).list();
assertTrue( l.size()==3 );
@ -334,14 +350,13 @@ public class MultiTableTest extends LegacyTestCase {
t = s.beginTransaction();
s.update(multi, mid);
s.delete(multi);
assertTrue( s.delete("from Top")==2);
assertEquals( 2, doDelete( s, "from Top" ) );
t.commit();
s.close();
}
public void testMultiTableGeneratedId() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Multi multi = new Multi();
@ -400,7 +415,7 @@ public class MultiTableTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
Iterator iter = s.iterate("select\n\nt from Top t where t.count>0");
Iterator iter = s.createQuery( "select\n\nt from Top t where t.count>0" ).iterate();
boolean foundSimp = false;
boolean foundMulti = false;
boolean foundSubMulti = false;
@ -411,30 +426,31 @@ public class MultiTableTest extends LegacyTestCase {
if ( o instanceof SubMulti ) foundSubMulti = true;
}
assertTrue( foundSimp&&foundMulti&&foundSubMulti );
s.find("from Multi m where m.count>0 and m.extraProp is not null");
s.find("from Top m where m.count>0 and m.name is not null");
s.find("from Lower m where m.other is not null");
s.find("from Multi m where m.other.id = 1");
s.find("from SubMulti m where m.amount > 0.0");
s.createQuery( "from Multi m where m.count>0 and m.extraProp is not null" ).list();
s.createQuery( "from Top m where m.count>0 and m.name is not null" ).list();
s.createQuery( "from Lower m where m.other is not null" ).list();
s.createQuery( "from Multi m where m.other.id = 1" ).list();
s.createQuery( "from SubMulti m where m.amount > 0.0" ).list();
assertTrue(
s.find("from Multi").size()==2
s.createQuery( "from Multi" ).list().size()==2
);
/*assertTrue(
s.find("from m in class Multi where m.class = Multi").size()==1
);*/
assertTrue(
s.find("from Top").size()==3
s.createQuery( "from Top" ).list().size()==3
);
assertTrue(
s.find("from Lower").size()==0
s.createQuery( "from Lower" ).list().size()==0
);
assertTrue(
s.find("from SubMulti").size()==1
s.createQuery( "from SubMulti" ).list().size()==1
);
s.find("from Lower ls join ls.bag s where s.id is not null");
if ( !(getDialect() instanceof MySQLDialect) ) s.find("from SubMulti sm where exists elements(sm.children)");
s.createQuery( "from Lower ls join ls.bag s where s.id is not null" ).list();
if ( !(getDialect() instanceof MySQLDialect) )
s.createQuery( "from SubMulti sm where exists elements(sm.children)" ).list();
t.commit();
s.close();
@ -451,7 +467,7 @@ public class MultiTableTest extends LegacyTestCase {
t = s.beginTransaction();
s.update( multi, multiId );
s.delete(multi);
assertTrue( s.delete("from Top")==2);
assertEquals( 2, doDelete( s, "from Top" ) );
t.commit();
s.close();
@ -460,7 +476,7 @@ public class MultiTableTest extends LegacyTestCase {
public void testMultiTableCollections() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
assertTrue( s.find("from Top").size()==0 );
assertTrue( s.createQuery( "from Top" ).list().size()==0 );
Multi multi = new Multi();
multi.setExtraProp("extra");
multi.setName("name");
@ -499,7 +515,7 @@ public class MultiTableTest extends LegacyTestCase {
if ( o instanceof Multi ) foundMulti++;
}
assertTrue( foundSimple==2 && foundMulti==1 );
assertTrue( s.delete("from Top")==3 );
assertEquals( 3, doDelete( s, "from Top" ) );
t.commit();
s.close();
}
@ -507,7 +523,7 @@ public class MultiTableTest extends LegacyTestCase {
public void testMultiTableManyToOne() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
assertTrue( s.find("from Top").size()==0 );
assertTrue( s.createQuery( "from Top" ).list().size()==0 );
Multi multi = new Multi();
multi.setExtraProp("extra");
multi.setName("name");
@ -573,31 +589,34 @@ public class MultiTableTest extends LegacyTestCase {
assertTrue( po.getSet().size()==2 );
assertTrue( po.getList().size()==1 );
s.delete(po);
assertTrue( s.find("from Top").size()==0 );
assertTrue( s.createQuery( "from Top" ).list().size()==0 );
t.commit();
s.close();
}
public void testOneToOne() throws Exception {
Session s = openSession();
s.beginTransaction();
Lower ls = new Lower();
Serializable id = s.save(ls);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
s.load(Lower.class, id);
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.delete( s.load(Lower.class, id) );
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
public void testCollectionPointer() throws Exception {
Session sess = openSession();
sess.beginTransaction();
Lower ls = new Lower();
List list = new ArrayList();
ls.setBag(list);
@ -606,16 +625,15 @@ public class MultiTableTest extends LegacyTestCase {
sess.save(s);
sess.flush();
list.add(s);
sess.flush();
sess.connection().commit();
sess.getTransaction().commit();
sess.close();
sess = openSession();
sess.beginTransaction();
ls = (Lower) sess.load(Lower.class, id);
assertTrue( ls.getBag().size()==1 );
sess.delete("from java.lang.Object");
sess.flush();
sess.connection().commit();
doDelete( sess, "from java.lang.Object" );
sess.getTransaction().commit();
sess.close();
}

View File

@ -67,6 +67,7 @@ public class ParentChildTest extends LegacyTestCase {
public void testReplicate() throws Exception {
Session s = openSession();
s.beginTransaction();
Container baz = new Container();
Contained f = new Contained();
List list = new ArrayList();
@ -77,30 +78,29 @@ public class ParentChildTest extends LegacyTestCase {
baz.setBag(list2);
s.save(f);
s.save(baz);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.replicate(baz, ReplicationMode.OVERWRITE);
// HHH-2378
SessionImpl x = (SessionImpl)s;
EntityEntry entry = x.getPersistenceContext().getEntry( baz );
assertNull(entry.getVersion());
s.flush();
s.connection().commit();
// ~~~~~~~
s.getTransaction().commit();
s.close();
s = openSession();
s.replicate(baz, ReplicationMode.IGNORE);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
s.delete(baz);
s.delete(f);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
@ -108,7 +108,7 @@ public class ParentChildTest extends LegacyTestCase {
Session s = openSession();
Transaction t = s.beginTransaction();
Serializable id = s.save( new Parent() );
assertTrue( s.find("from Parent p left join fetch p.child").size()==1 );
assertTrue( s.createQuery( "from Parent p left join fetch p.child" ).list().size()==1 );
t.commit();
s.close();
@ -116,8 +116,8 @@ public class ParentChildTest extends LegacyTestCase {
t = s.beginTransaction();
Parent p = (Parent) s.createQuery("from Parent p left join fetch p.child").uniqueResult();
assertTrue( p.getChild()==null );
s.find("from Parent p join p.child c where c.x > 0");
s.find("from Child c join c.parent p where p.x > 0");
s.createQuery( "from Parent p join p.child c where c.x > 0" ).list();
s.createQuery( "from Child c join c.parent p where p.x > 0" ).list();
t.commit();
s.close();
@ -177,7 +177,7 @@ public class ParentChildTest extends LegacyTestCase {
s.delete(foo);
s.delete( s.get(Foo.class, id2) );
s.delete( s.get(Foo.class, "xyzid") );
assertTrue( s.delete("from java.lang.Object")==3 );
assertEquals( 2, doDelete( s, "from java.lang.Object" ) );
t.commit();
s.close();
@ -322,9 +322,9 @@ public class ParentChildTest extends LegacyTestCase {
assertTrue( Hibernate.isInitialized(baz.getTopGlarchez()) ); //cos it is nonlazy
assertTrue( !Hibernate.isInitialized(baz.getFooSet()) );
list = s.createCriteria(Child.class).setFetchMode("parent", FetchMode.JOIN).list();
s.delete("from Glarch g");
s.createCriteria(Child.class).setFetchMode("parent", FetchMode.JOIN).list();
doDelete( s, "from Glarch g" );
s.delete( s.get(Foo.class, foo1.getKey() ) );
s.delete( s.get(Foo.class, foo2.getKey() ) );
s.delete(baz);
@ -429,57 +429,60 @@ public class ParentChildTest extends LegacyTestCase {
sx.setName("s");
s.save( sx, new Long(5) );
assertTrue(
s.find("select c from ContainerX c, Simple s where c.oneToMany[2] = s")
.size() == 1
s.createQuery( "select c from ContainerX c, Simple s where c.oneToMany[2] = s" ).list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c, Simple s where c.manyToMany[2] = s")
.size() == 1
s.createQuery( "select c from ContainerX c, Simple s where c.manyToMany[2] = s" ).list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c, Simple s where s = c.oneToMany[2]")
.size() == 1
s.createQuery( "select c from ContainerX c, Simple s where s = c.oneToMany[2]" ).list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c, Simple s where s = c.manyToMany[2]")
.size() == 1
s.createQuery( "select c from ContainerX c, Simple s where s = c.manyToMany[2]" ).list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c where c.oneToMany[0].name = 's'")
.size() == 1
s.createQuery( "select c from ContainerX c where c.oneToMany[0].name = 's'" ).list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c where c.manyToMany[0].name = 's'")
.size() == 1
s.createQuery( "select c from ContainerX c where c.manyToMany[0].name = 's'" ).list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c where 's' = c.oneToMany[2 - 2].name")
.size() == 1
s.createQuery( "select c from ContainerX c where 's' = c.oneToMany[2 - 2].name" ).list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c where 's' = c.manyToMany[(3+1)/4-1].name")
.size() == 1
s.createQuery( "select c from ContainerX c where 's' = c.manyToMany[(3+1)/4-1].name" ).list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c where c.oneToMany[ c.manyToMany[0].count ].name = 's'")
.size() == 1
s.createQuery( "select c from ContainerX c where c.oneToMany[ c.manyToMany[0].count ].name = 's'" )
.list()
.size() == 1
);
assertTrue(
s.find("select c from ContainerX c where c.manyToMany[ c.oneToMany[0].count ].name = 's'")
.size() == 1
s.createQuery( "select c from ContainerX c where c.manyToMany[ c.oneToMany[0].count ].name = 's'" )
.list()
.size() == 1
);
if ( ! ( getDialect() instanceof MySQLDialect ) && !(getDialect() instanceof org.hibernate.dialect.TimesTenDialect) ) {
assertTrue(
s.find("select c from ContainerX c where c.manyToMany[ maxindex(c.manyToMany) ].count = 2")
.size() == 1
s.createQuery( "select c from ContainerX c where c.manyToMany[ maxindex(c.manyToMany) ].count = 2" )
.list()
.size() == 1
);
}
assertTrue( s.contains(cd) );
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof HSQLDialect) ) {
s.filter( c.getBag(), "where 0 in elements(this.bag)" );
s.filter( c.getBag(), "where 0 in elements(this.lazyBag)" );
s.createFilter( c.getBag(), "where 0 in elements(this.bag)" ).list();
s.createFilter( c.getBag(), "where 0 in elements(this.lazyBag)" ).list();
}
s.find("select count(comp.name) from ContainerX c join c.components comp");
s.createQuery( "select count(comp.name) from ContainerX c join c.components comp" ).list();
s.delete(cd);
s.delete(c);
s.delete(s1);
@ -521,19 +524,19 @@ public class ParentChildTest extends LegacyTestCase {
assertTrue( "1-1 update", c.getCount()==32 );
assertTrue(
"1-1 query",
s.find("from Child c where c.parent.count=66").size()==1
s.createQuery( "from Child c where c.parent.count=66" ).list().size()==1
);
assertTrue(
"1-1 query",
( (Object[]) s.find("from Parent p join p.child c where p.count=66").get(0) ).length==2
);
s.find("select c, c.parent from Child c order by c.parent.count");
s.find("select c, c.parent from Child c where c.parent.count=66 order by c.parent.count");
s.iterate("select c, c.parent, c.parent.count from Child c order by c.parent.count");
assertTrue(
"1-1 query",
s.find("FROM Parent AS p WHERE p.count = ?", new Integer(66), Hibernate.INTEGER).size()==1
( (Object[]) s.createQuery( "from Parent p join p.child c where p.count=66" ).list().get(0) ).length==2
);
s.createQuery( "select c, c.parent from Child c order by c.parent.count" ).list();
s.createQuery( "select c, c.parent from Child c where c.parent.count=66 order by c.parent.count" ).list();
s.createQuery( "select c, c.parent, c.parent.count from Child c order by c.parent.count" ).iterate();
List result = s.createQuery( "FROM Parent AS p WHERE p.count = ?" )
.setParameter( 0, new Integer(66), Hibernate.INTEGER )
.list();
assertEquals( "1-1 query", 1, result.size() );
s.delete(c); s.delete(p);
t.commit();
s.close();
@ -566,7 +569,6 @@ public class ParentChildTest extends LegacyTestCase {
}
public void testManyToMany() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Container c = new Container();
@ -606,9 +608,9 @@ public class ParentChildTest extends LegacyTestCase {
assertTrue( c.getManyToMany().size()==1 );
c1 = (Contained) s.load( Contained.class, new Long(c1.getId()) );
assertTrue( c1.getBag().size()==0 );
assertTrue( s.delete("from ContainerX c")==1 );
assertTrue( s.delete("from Contained")==1 );
assertTrue( s.delete("from Simple")==2 );
assertEquals( 1, doDelete( s, "from ContainerX c" ) );
assertEquals( 1, doDelete( s, "from Contained" ) );
assertEquals( 2, doDelete( s, "from Simple" ) );
t.commit();
s.close();
}
@ -657,7 +659,9 @@ public class ParentChildTest extends LegacyTestCase {
t = s.beginTransaction();
Long count = (Long) s.createQuery("select count(*) from ContainerX as c join c.components as ce join ce.simple as s where ce.name='foo'").uniqueResult();
assertTrue( count.intValue()==1 );
List res = s.find("select c, s from ContainerX as c join c.components as ce join ce.simple as s where ce.name='foo'");
List res = s.createQuery(
"select c, s from ContainerX as c join c.components as ce join ce.simple as s where ce.name='foo'"
).list();
assertTrue(res.size()==1);
t.commit();
s.close();
@ -734,9 +738,9 @@ public class ParentChildTest extends LegacyTestCase {
c.getManyToMany().clear();
c.getComposites().clear();
c.getComponents().clear();
s.delete("from Simple");
s.delete("from Many");
s.delete("from One");
doDelete( s, "from Simple" );
doDelete( s, "from Many" );
doDelete( s, "from One" );
t.commit();
s.close();
@ -761,23 +765,24 @@ public class ParentChildTest extends LegacyTestCase {
cic.setOne( new One() );
list.add(cic);
Session s = openSession();
s.beginTransaction();
s.save(c);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s=openSession();
c = (Container) s.iterate("from ContainerX c").next();
s.beginTransaction();
c = (Container) s.createQuery( "from ContainerX c" ).iterate().next();
cic = (Container.ContainerInnerClass) c.getCascades().iterator().next();
assertTrue( cic.getMany()!=null && cic.getOne()!=null );
assertTrue( c.getCascades().size()==1 );
s.delete(c);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
c = new Container();
s = openSession();
s.beginTransaction();
s.save(c);
list = new ArrayList();
c.setCascades(list);
@ -785,23 +790,21 @@ public class ParentChildTest extends LegacyTestCase {
cic.setMany( new Many() );
cic.setOne( new One() );
list.add(cic);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s=openSession();
c = (Container) s.iterate("from ContainerX c").next();
s.beginTransaction();
c = (Container) s.createQuery( "from ContainerX c" ).iterate().next();
cic = (Container.ContainerInnerClass) c.getCascades().iterator().next();
assertTrue( cic.getMany()!=null && cic.getOne()!=null );
assertTrue( c.getCascades().size()==1 );
s.delete(c);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
public void testBag() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Container c = new Container();
@ -822,14 +825,14 @@ public class ParentChildTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
c = (Container) s.find("from ContainerX c").get(0);
c = (Container) s.createQuery( "from ContainerX c" ).list().get(0);
c.getLazyBag().size();
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
c = (Container) s.find("from ContainerX c").get(0);
c = (Container) s.createQuery( "from ContainerX c" ).list().get(0);
Contained c3 = new Contained();
//c.getBag().add(c3);
//c3.getBag().add(c);
@ -840,7 +843,7 @@ public class ParentChildTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
c = (Container) s.find("from ContainerX c").get(0);
c = (Container) s.createQuery( "from ContainerX c" ).list().get(0);
Contained c4 = new Contained();
c.getLazyBag().add(c4);
c4.getLazyBag().add(c);
@ -851,7 +854,7 @@ public class ParentChildTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
c = (Container) s.find("from ContainerX c").get(0);
c = (Container) s.createQuery( "from ContainerX c" ).list().get(0);
Iterator i = c.getBag().iterator();
int j=0;
while ( i.hasNext() ) {
@ -873,7 +876,6 @@ public class ParentChildTest extends LegacyTestCase {
s.delete( s.load(Contained.class, new Long( c3.getId() ) ) );
t.commit();
s.close();
}
public void testCircularCascade() throws Exception {
@ -913,15 +915,17 @@ public class ParentChildTest extends LegacyTestCase {
assertTrue( c.getOther().getClazz()==Qux.class);
assertTrue( c.getOther().getOther().getOther()==c);
assertTrue( c.getAnyEntity()==c.getOther() );
assertTrue( s.delete("from Universe")==3 );
assertEquals( 3, doDelete( s, "from Universe" ) );
tx.commit();
s.close();
}
public void testDeleteEmpty() throws Exception {
Session s = openSession();
assertTrue( s.delete("from Simple")==0 );
assertTrue( s.delete("from Universe")==0 );
s.beginTransaction();
assertEquals( 0, doDelete( s, "from Simple" ) );
assertEquals( 0, doDelete( s, "from Universe" ) );
s.getTransaction().commit();
s.close();
}
@ -1004,26 +1008,26 @@ public class ParentChildTest extends LegacyTestCase {
public void testObjectType() throws Exception {
Session s = openSession();
s.beginTransaction();
Parent g = new Parent();
Foo foo = new Foo();
g.setAny(foo);
s.save(g);
s.save(foo);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
g = (Parent) s.load( Parent.class, new Long( g.getId() ) );
assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy );
s.delete( g.getAny() );
s.delete(g);
s.flush();
s.connection().commit();
s.getTransaction().commit();
s.close();
}
public void testLoadAfterNonExists() throws HibernateException, SQLException {
Session session = openSession();
if ( (getDialect() instanceof MySQLDialect) ) {
session.connection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
@ -1038,8 +1042,9 @@ public class ParentChildTest extends LegacyTestCase {
// this is correct
}
// Next, lets create that entity under the covers
// Next, lets create that entity "under the covers"
Session anotherSession = getSessions().openSession();
anotherSession.beginTransaction();
Simple myNewSimple = new Simple();
myNewSimple.setName("My under the radar Simple entity");
myNewSimple.setAddress("SessionCacheTest.testLoadAfterNonExists");
@ -1047,29 +1052,19 @@ public class ParentChildTest extends LegacyTestCase {
myNewSimple.setDate( new Date() );
myNewSimple.setPay( new Float(100000000) );
anotherSession.save( myNewSimple, new Long(-1) );
anotherSession.flush();
anotherSession.connection().commit();
anotherSession.getTransaction().commit();
anotherSession.close();
// Verify that the original session is still able to see the new entry...
//try {
session.load( Simple.class, new Long(-1) );
/*fail();
}
catch(ObjectNotFoundException onfe) {
}*/
// Now, lets clear the original session at which point it should be able to see
// the new entity
// Now, lets make sure the original session can see the created row...
session.clear();
try {
Simple dummy = (Simple) session.load( Simple.class, new Long(-1) );
Simple dummy = (Simple) session.get( Simple.class, new Long(-1) );
assertNotNull("Unable to locate entity Simple with id = -1", dummy);
}
catch(ObjectNotFoundException onfe) {
fail("Unable to locate entity Simple with id = -1");
}
session.connection().commit();
session.getTransaction().commit();
session.close();
}

View File

@ -59,7 +59,7 @@ public class SQLFunctionsTest extends LegacyTestCase {
Session s = openSession();
Transaction t = s.beginTransaction();
Iterator iter = s.iterate("select max(s.count) from Simple s");
Iterator iter = s.createQuery( "select max(s.count) from Simple s" ).iterate();
if ( getDialect() instanceof MySQLDialect ) assertTrue( iter.hasNext() && iter.next()==null );
@ -72,20 +72,20 @@ public class SQLFunctionsTest extends LegacyTestCase {
// Test to make sure allocating an specified object operates correctly.
assertTrue(
s.find("select new org.hibernate.test.legacy.S(s.count, s.address) from Simple s").size() == 1
s.createQuery( "select new org.hibernate.test.legacy.S(s.count, s.address) from Simple s" ).list().size() == 1
);
// Quick check the base dialect functions operate correctly
assertTrue(
s.find("select max(s.count) from Simple s").size() == 1
s.createQuery( "select max(s.count) from Simple s" ).list().size() == 1
);
assertTrue(
s.find("select count(*) from Simple s").size() == 1
s.createQuery( "select count(*) from Simple s" ).list().size() == 1
);
if ( getDialect() instanceof Oracle9iDialect ) {
// Check Oracle Dialect mix of dialect functions - no args (no parenthesis and single arg functions
java.util.List rset = s.find("select s.name, sysdate(), trunc(s.pay), round(s.pay) from Simple s");
List rset = s.createQuery( "select s.name, sysdate(), trunc(s.pay), round(s.pay) from Simple s" ).list();
assertNotNull("Name string should have been returned",(((Object[])rset.get(0))[0]));
assertNotNull("Todays Date should have been returned",(((Object[])rset.get(0))[1]));
assertEquals("trunc(45.8) result was incorrect ", new Float(45), ( (Object[]) rset.get(0) )[2] );
@ -95,24 +95,29 @@ public class SQLFunctionsTest extends LegacyTestCase {
s.update(simple);
// Test type conversions while using nested functions (Float to Int).
rset = s.find("select abs(round(s.pay)) from Simple s");
rset = s.createQuery( "select abs(round(s.pay)) from Simple s" ).list();
assertEquals("abs(round(-45.8)) result was incorrect ", new Float(46), rset.get(0));
// Test a larger depth 3 function example - Not a useful combo other than for testing
assertTrue(
s.find("select trunc(round(sysdate())) from Simple s").size() == 1
s.createQuery( "select trunc(round(sysdate())) from Simple s" ).list().size() == 1
);
// Test the oracle standard NVL funtion as a test of multi-param functions...
simple.setPay(null);
s.update(simple);
Integer value = (Integer) s.find("select MOD( NVL(s.pay, 5000), 2 ) from Simple as s where s.id = 10").get(0);
Integer value = (Integer) s.createQuery(
"select MOD( NVL(s.pay, 5000), 2 ) from Simple as s where s.id = 10"
).list()
.get(0);
assertTrue( 0 == value.intValue() );
}
if ( (getDialect() instanceof HSQLDialect) ) {
// Test the hsql standard MOD funtion as a test of multi-param functions...
Integer value = (Integer) s.find("select MOD(s.count, 2) from Simple as s where s.id = 10" ).get(0);
Integer value = (Integer) s.createQuery( "select MOD(s.count, 2) from Simple as s where s.id = 10" )
.list()
.get(0);
assertTrue( 0 == value.intValue() );
}
@ -358,32 +363,35 @@ public class SQLFunctionsTest extends LegacyTestCase {
s.save(simple, new Long(10) );
if ( getDialect() instanceof DB2Dialect) {
s.find("from Simple s where repeat('foo', 3) = 'foofoofoo'");
s.find("from Simple s where repeat(s.name, 3) = 'foofoofoo'");
s.find("from Simple s where repeat( lower(s.name), 3 + (1-1) / 2) = 'foofoofoo'");
s.createQuery( "from Simple s where repeat('foo', 3) = 'foofoofoo'" ).list();
s.createQuery( "from Simple s where repeat(s.name, 3) = 'foofoofoo'" ).list();
s.createQuery( "from Simple s where repeat( lower(s.name), 3 + (1-1) / 2) = 'foofoofoo'" ).list();
}
assertTrue(
s.find("from Simple s where upper( s.name ) ='SIMPLE 1'").size()==1
s.createQuery( "from Simple s where upper( s.name ) ='SIMPLE 1'" ).list().size()==1
);
if ( !(getDialect() instanceof HSQLDialect) ) {
assertTrue(
s.find("from Simple s where not( upper( s.name ) ='yada' or 1=2 or 'foo'='bar' or not('foo'='foo') or 'foo' like 'bar' )").size()==1
s.createQuery(
"from Simple s where not( upper( s.name ) ='yada' or 1=2 or 'foo'='bar' or not('foo'='foo') or 'foo' like 'bar' )"
).list()
.size()==1
);
}
if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SybaseDialect) && !(getDialect() instanceof SQLServerDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof InterbaseDialect) && !(getDialect() instanceof TimesTenDialect) ) { //My SQL has a funny concatenation operator
assertTrue(
s.find("from Simple s where lower( s.name || ' foo' ) ='simple 1 foo'").size()==1
s.createQuery( "from Simple s where lower( s.name || ' foo' ) ='simple 1 foo'" ).list().size()==1
);
}
if ( (getDialect() instanceof SybaseDialect) ) {
assertTrue(
s.find("from Simple s where lower( s.name + ' foo' ) ='simple 1 foo'").size()==1
s.createQuery( "from Simple s where lower( s.name + ' foo' ) ='simple 1 foo'" ).list().size()==1
);
}
if ( (getDialect() instanceof MckoiDialect) || (getDialect() instanceof TimesTenDialect)) {
assertTrue(
s.find("from Simple s where lower( concat(s.name, ' foo') ) ='simple 1 foo'").size()==1
s.createQuery( "from Simple s where lower( concat(s.name, ' foo') ) ='simple 1 foo'" ).list().size()==1
);
}
@ -394,44 +402,61 @@ public class SQLFunctionsTest extends LegacyTestCase {
s.save( other, new Long(20) );
//s.find("from Simple s where s.name ## 'cat|rat|bag'");
assertTrue(
s.find("from Simple s where upper( s.other.name ) ='SIMPLE 2'").size()==1
s.createQuery( "from Simple s where upper( s.other.name ) ='SIMPLE 2'" ).list().size()==1
);
assertTrue(
s.find("from Simple s where not ( upper( s.other.name ) ='SIMPLE 2' )").size()==0
s.createQuery( "from Simple s where not ( upper( s.other.name ) ='SIMPLE 2' )" ).list().size()==0
);
assertTrue(
s.find("select distinct s from Simple s where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2").size()==1
s.createQuery(
"select distinct s from Simple s where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2"
).list()
.size()==1
);
assertTrue(
s.find("select s from Simple s where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2 order by s.other.count").size()==1
s.createQuery(
"select s from Simple s where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2 order by s.other.count"
).list()
.size()==1
);
Simple min = new Simple();
min.setCount(-1);
s.save(min, new Long(30) );
if ( ! (getDialect() instanceof MySQLDialect) && ! (getDialect() instanceof HSQLDialect) ) { //My SQL has no subqueries
assertTrue(
s.find("from Simple s where s.count > ( select min(sim.count) from Simple sim )").size()==2
s.createQuery( "from Simple s where s.count > ( select min(sim.count) from Simple sim )" )
.list()
.size()==2
);
t.commit();
t = s.beginTransaction();
assertTrue(
s.find("from Simple s where s = some( select sim from Simple sim where sim.count>=0 ) and s.count >= 0").size()==2
s.createQuery(
"from Simple s where s = some( select sim from Simple sim where sim.count>=0 ) and s.count >= 0"
).list()
.size()==2
);
assertTrue(
s.find("from Simple s where s = some( select sim from Simple sim where sim.other.count=s.other.count ) and s.other.count > 0").size()==1
s.createQuery(
"from Simple s where s = some( select sim from Simple sim where sim.other.count=s.other.count ) and s.other.count > 0"
).list()
.size()==1
);
}
Iterator iter = s.iterate("select sum(s.count) from Simple s group by s.count having sum(s.count) > 10");
Iterator iter = s.createQuery( "select sum(s.count) from Simple s group by s.count having sum(s.count) > 10" )
.iterate();
assertTrue( iter.hasNext() );
assertEquals( new Long(12), iter.next() );
assertTrue( !iter.hasNext() );
if ( ! (getDialect() instanceof MySQLDialect) ) {
iter = s.iterate("select s.count from Simple s group by s.count having s.count = 12");
iter = s.createQuery( "select s.count from Simple s group by s.count having s.count = 12" ).iterate();
assertTrue( iter.hasNext() );
}
s.iterate("select s.id, s.count, count(t), max(t.date) from Simple s, Simple t where s.count = t.count group by s.id, s.count order by s.count");
s.createQuery(
"select s.id, s.count, count(t), max(t.date) from Simple s, Simple t where s.count = t.count group by s.id, s.count order by s.count"
).iterate();
Query q = s.createQuery("from Simple s");
q.setMaxResults(10);
@ -594,7 +619,7 @@ public class SQLFunctionsTest extends LegacyTestCase {
s = openSession();
t = s.beginTransaction();
List result = s.find(query);
List result = s.createQuery( query ).list();
assertTrue( result.size() == 1 );
assertTrue(result.get(0) instanceof Simple);
s.delete( result.get(0) );

View File

@ -28,7 +28,6 @@ import junit.framework.Test;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.cfg.DefaultNamingStrategy;
import org.hibernate.util.StringHelper;
import org.hibernate.Session;