Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test
In directory sc8-pr-cvs1:/tmp/cvs-serv15856/sf/hibernate/test
Modified Files:
FooBarTest.java MasterDetailTest.java
Log Message:
added new criteria + expression API (experimental)
Index: FooBarTest.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** FooBarTest.java 6 Mar 2003 11:11:45 -0000 1.38
--- FooBarTest.java 8 Mar 2003 06:31:23 -0000 1.39
***************
*** 12,16 ****
import java.util.List;
import java.util.Locale;
- import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
--- 12,15 ----
***************
*** 20,23 ****
--- 19,23 ----
import junit.framework.Test;
import junit.framework.TestSuite;
+ import net.sf.hibernate.expression.Expression;
import net.sf.hibernate.Databinder;
import net.sf.hibernate.FlushMode;
***************
*** 136,154 ****
}
! /*public void testFindLike() throws Exception {
Session s = sessions.openSession();
Foo f = new Foo();
s.save(f);
s.flush();
! Map map = new HashMap();
! map.put( "integer", f.getInteger() );
! map.put( "string", f.getString() );
! map.put( "boolean", f.getBoolean() );
! List list = s.find(Foo.class, map);
assertTrue( list.size()==1 && list.get(0)==f );
s.delete(f);
s.flush();
s.close();
! }*/
public void testAfterDelete() throws Exception {
--- 136,170 ----
}
! public void testFindByCriteria() throws Exception {
Session s = sessions.openSession();
Foo f = new Foo();
s.save(f);
s.flush();
! List list = s.createCriteria(Foo.class)
! .add( Expression.eq( "integer", f.getInteger() ) )
! .add( Expression.like( "string", f.getString() ) )
! .add( Expression.eq( "boolean", f.getBoolean() ) )
! .list();
! assertTrue( list.size()==1 && list.get(0)==f );
! list = s.createCriteria(Foo.class)
! .add( Expression.or(
! Expression.and(
! Expression.eq( "integer", f.getInteger() ),
! Expression.like( "string", f.getString() )
! ),
! Expression.eq( "boolean", f.getBoolean() )
! ) )
! .list();
assertTrue( list.size()==1 && list.get(0)==f );
+ list = s.createCriteria(Foo.class).setMaxResults(5).list();
+ assertTrue( list.size()==1 && list.get(0)==f );
+ list = s.createCriteria(Foo.class).setMaxResults(0).list();
+ assertTrue( list.size()==0 );
+ list = s.createCriteria(Foo.class).setFirstResult(1).list();
+ assertTrue( list.size()==0 );
s.delete(f);
s.flush();
s.close();
! }
public void testAfterDelete() throws Exception {
Index: MasterDetailTest.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MasterDetailTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MasterDetailTest.java 23 Feb 2003 01:32:21 -0000 1.4
--- MasterDetailTest.java 8 Mar 2003 06:31:23 -0000 1.5
***************
*** 78,82 ****
}
-
public void testMasterDetail() throws Exception {
Session s = sessions.openSession();
--- 78,81 ----
|