Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv11798/sf/hibernate/test Modified Files: FooBarTest.java MasterDetailTest.java MultiTableTest.java ParentChildTest.java SQLFunctionsTest.java Log Message: refactored hql package (incomplete) Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** FooBarTest.java 22 Feb 2003 06:42:07 -0000 1.24 --- FooBarTest.java 23 Feb 2003 01:32:21 -0000 1.25 *************** *** 182,185 **** --- 182,188 ---- ).size()==1 ); s.find("from s in class Stuff where s.foo.string is not null"); + assertTrue( + s.find("from s in class Stuff where s.foo > 'a' order by s.foo").size()==1 + ); t.commit(); s.close(); *************** *** 856,859 **** --- 859,869 ---- s.save(foo2); foo.setFoo(foo2); + + s.find("select foo.foo.foo.string from foo in class Foo where foo.foo = 'bar'"); + s.find("select foo.foo.foo.foo.string from foo in class Foo where foo.foo.foo = 'bar'"); + s.find("select foo.foo.foo.string from foo in class Foo where foo.foo.foo.foo.string = 'bar'"); + s.find("select foo.string from foo in class Foo where foo.foo.foo.foo = foo.foo.foo"); + s.find("select foo.string from foo in class Foo where foo.foo.foo = 'bar' and foo.foo.foo.foo = 'baz'"); + s.find("select foo.string from foo in class Foo where foo.foo.foo.foo.string = 'a' and foo.foo.string = 'b'"); if ( dialect instanceof DB2Dialect) { *************** *** 2697,2700 **** --- 2707,2738 ---- hs.start(); hs.stop(); + } + + public void testPSCache() throws Exception { + Session s = sessions.openSession(); + for ( int i=0; i<10; i++ ) s.save( new Foo() ); + Query q = s.createQuery("from f in class Foo"); + q.setMaxResults(2); + q.setFirstResult(5); + assertTrue( q.list().size()==2 ); + q = s.createQuery("from f in class Foo"); + assertTrue( q.list().size()==10 ); + assertTrue( q.list().size()==10 ); + q.setMaxResults(3); + q.setFirstResult(3); + assertTrue( q.list().size()==3 ); + q = s.createQuery("from f in class Foo"); + assertTrue( q.list().size()==10 ); + s.connection().commit(); + s.close(); + s = sessions.openSession(); + q = s.createQuery("from f in class Foo"); + assertTrue( q.list().size()==10 ); + q.setMaxResults(5); + assertTrue( q.list().size()==5 ); + s.delete("from f in class Foo"); + s.connection().commit(); + s.close(); + } Index: MasterDetailTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MasterDetailTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MasterDetailTest.java 5 Jan 2003 02:11:23 -0000 1.3 --- MasterDetailTest.java 23 Feb 2003 01:32:21 -0000 1.4 *************** *** 2,11 **** package net.sf.hibernate.test; - import net.sf.hibernate.*; - import net.sf.hibernate.dialect.HSQLDialect; - import net.sf.hibernate.dialect.MySQLDialect; - import net.sf.hibernate.dialect.SAPDBDialect; - import net.sf.hibernate.dialect.SybaseDialect; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; --- 2,5 ---- *************** *** 19,22 **** --- 13,24 ---- import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.ObjectNotFoundException; + import net.sf.hibernate.Query; + import net.sf.hibernate.Session; + import net.sf.hibernate.Transaction; + import net.sf.hibernate.dialect.HSQLDialect; + import net.sf.hibernate.dialect.MySQLDialect; + import net.sf.hibernate.dialect.SAPDBDialect; + import net.sf.hibernate.dialect.SybaseDialect; public class MasterDetailTest extends TestCase { Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MultiTableTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MultiTableTest.java 15 Feb 2003 01:00:58 -0000 1.6 --- MultiTableTest.java 23 Feb 2003 01:32:21 -0000 1.7 *************** *** 45,48 **** --- 45,49 ---- s.find("from s in class Simple where s.count=1"); s.find("select s.count from s in class Simple, ls in class LessSimple where ls.another=s"); + s.find("select ls.bag.elements, ls.set.elements from ls in class LessSimple"); s.iterate("from s in class LessSimple"); s.iterate("from s in class Simple"); *************** *** 171,174 **** --- 172,176 ---- s.find("from ls in class LessSimple, s in ls.bag.elements where s.id is not null"); + s.find("from ls in class LessSimple, s in ls.set.elements where s.id is not null"); s.find("from sm in class SubMulti where exists sm.children.elements"); Index: ParentChildTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ParentChildTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ParentChildTest.java 19 Feb 2003 02:02:16 -0000 1.6 --- ParentChildTest.java 23 Feb 2003 01:32:21 -0000 1.7 *************** *** 8,16 **** import java.util.List; - import net.sf.hibernate.*; - import net.sf.hibernate.dialect.MySQLDialect; - import junit.framework.Test; import junit.framework.TestSuite; public class ParentChildTest extends TestCase { --- 8,18 ---- import java.util.List; import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.Hibernate; + import net.sf.hibernate.LockMode; + import net.sf.hibernate.Session; + import net.sf.hibernate.Transaction; + import net.sf.hibernate.dialect.MySQLDialect; public class ParentChildTest extends TestCase { Index: SQLFunctionsTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/SQLFunctionsTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SQLFunctionsTest.java 15 Feb 2003 01:00:58 -0000 1.4 --- SQLFunctionsTest.java 23 Feb 2003 01:32:21 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.Hibernate; import net.sf.hibernate.Query; import net.sf.hibernate.Session; *************** *** 160,164 **** } ! /*public void testBlobClob() throws Exception { Session s = sessions.openSession(); Blobber b = new Blobber(); --- 161,165 ---- } ! public void testBlobClob() throws Exception { Session s = sessions.openSession(); Blobber b = new Blobber(); *************** *** 183,187 **** b2.setBlob( b.getBlob() ); b.setBlob(null); ! assertTrue( b.getClob().getSubString(1, 3).equals("fab") ); b.getClob().getSubString(1, 6); b.getClob().setString(1, "qwerty"); --- 184,188 ---- b2.setBlob( b.getBlob() ); b.setBlob(null); ! //assertTrue( b.getClob().getSubString(1, 3).equals("fab") ); b.getClob().getSubString(1, 6); b.getClob().setString(1, "qwerty"); *************** *** 189,193 **** s.connection().commit(); s.close(); ! }*/ --- 190,238 ---- s.connection().commit(); s.close(); ! ! s = sessions.openSession(); ! 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.close(); ! ! s = sessions.openSession(); ! 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.close(); ! ! ! /*InputStream is = getClass().getClassLoader().getResourceAsStream("jdbc20.pdf"); ! s = sessions.openSession(); ! b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); ! System.out.println( is.available() ); ! int size = is.available(); ! b.setBlob( Hibernate.createBlob( is, is.available() ) ); ! s.flush(); ! s.connection().commit(); ! ResultSet rs = s.connection().createStatement().executeQuery("select datalength(blob_) from blobber where id=" + b.getId() ); ! rs.next(); ! assertTrue( size==rs.getInt(1) ); ! rs.close(); ! s.close(); ! ! s = sessions.openSession(); ! b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); ! File f = new File("C:/foo.pdf"); ! f.createNewFile(); ! FileOutputStream fos = new FileOutputStream(f); ! Blob blob = b.getBlob(); ! byte[] bytes = blob.getBytes( 1, (int) blob.length() ); ! System.out.println( bytes.length ); ! fos.write(bytes); ! fos.flush(); ! fos.close(); ! s.close();*/ ! ! } |