From: <one...@us...> - 2003-01-09 09:40:24
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv8251/cirrus/hibernate/test Modified Files: Master.java MasterDetailTest.java Log Message: Mark Woon's patch to limit length of aliases Index: Master.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Master.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Master.java 15 Oct 2002 03:36:10 -0000 1.8 --- Master.java 9 Jan 2003 09:40:20 -0000 1.9 *************** *** 21,25 **** } ! private void setDetails(Set details) { this.details = details; } --- 21,25 ---- } ! void setDetails(Set details) { this.details = details; } Index: MasterDetailTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/MasterDetailTest.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** MasterDetailTest.java 7 Dec 2002 08:20:53 -0000 1.42 --- MasterDetailTest.java 9 Jan 2003 09:40:20 -0000 1.43 *************** *** 367,370 **** --- 367,415 ---- } + + public void testUpdateCollections() throws Exception { + Session s = sessions.openSession(); + Master m = new Master(); + Serializable mid = s.save(m); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + m.setDetails( new HashSet() ); + Detail d1 = new Detail(); + Detail d2 = new Detail(); + //s.flush(); + d1.setMaster(m); + d2.setMaster(m); + m.addDetail(d1); + m.addDetail(d2); + s.update(m, mid); + + Iterator iter = m.getDetails().iterator(); + while ( iter.hasNext() ) s.save( iter.next() ); + s.flush(); + s.connection().commit(); + s.close(); + + + s = sessions.openSession(); + m = (Master) s.load(Master.class, mid); + iter = m.getDetails().iterator(); + int i=0; + while ( iter.hasNext() ) { + assertTrue( iter.next()!=null ); + i++; + } + assertTrue(i==2); + iter = m.getDetails().iterator(); + while ( iter.hasNext() ) s.delete( iter.next() ); + s.delete(m); + s.flush(); + s.connection().commit(); + s.close(); + + } + public void testMultiLevelCascade() throws Exception { Session s = sessions.openSession(); |