From: <one...@us...> - 2002-11-05 10:42:55
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory usw-pr-cvs1:/tmp/cvs-serv30123/hibernate/test Modified Files: Multi.hbm.xml MultiTableTest.java Log Message: support native id generation for normalized mappings Index: Multi.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Multi.hbm.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Multi.hbm.xml 5 Nov 2002 03:44:02 -0000 1.11 --- Multi.hbm.xml 5 Nov 2002 10:42:52 -0000 1.12 *************** *** 5,9 **** <class name="cirrus.hibernate.test.Simple" table="rootclass"> <id type="long" column="id_" > ! <generator class="assigned"/> </id> <version name="count" column="count_"/> --- 5,9 ---- <class name="cirrus.hibernate.test.Simple" table="rootclass"> <id type="long" column="id_" > ! <generator class="native"/> </id> <version name="count" column="count_"/> Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/MultiTableTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MultiTableTest.java 5 Nov 2002 03:44:02 -0000 1.9 --- MultiTableTest.java 5 Nov 2002 10:42:52 -0000 1.10 *************** *** 18,66 **** } - public void testMultiTableCollections() throws Exception { - Session s = sessions.openSession(); - Transaction t = s.beginTransaction(); - Multi multi = new Multi(); - multi.setExtraProp("extra"); - //multi.setCount(666); - multi.setName("name"); - Simple simp = new Simple(); - simp.setDate( new Date() ); - simp.setName("simp"); - //simp.setCount(132); - s.save( multi, new Long(123) ); - s.save( simp, new Long(1234) ); - LessSimple ls = new LessSimple(); - ls.setOther(ls); - ls.setAnother(ls); - ls.setYetanother(ls); - ls.setName("Less Simple"); - Set set = new HashSet(); - ls.setSet(set); - set.add(multi); - set.add(simp); - s.save( ls, new Long(2) ); - t.commit(); - s.close(); - - s = sessions.openSession(); - t = s.beginTransaction(); - ls = (LessSimple) s.load( LessSimple.class, new Long(2) ); - assertTrue( ls.getOther()==ls && ls.getAnother()==ls && ls.getYetanother()==ls ); - assertTrue( ls.getSet().size()==2 ); - Iterator iter = ls.getSet().iterator(); - int foundMulti = 0; - int foundSimple = 0; - while ( iter.hasNext() ) { - Object o = iter.next(); - if ( o instanceof Simple ) foundSimple++; - if ( o instanceof Multi ) foundMulti++; - } - assertTrue( foundSimple==2 && foundMulti==1 ); - s.delete("from s in class Simple"); - t.commit(); - s.close(); - } - public void testMultiTable() throws Exception { Session s = sessions.openSession(); --- 18,21 ---- *************** *** 145,151 **** --- 100,164 ---- s.update( multi, new Long(123) ); s.delete(multi); + assertTrue( s.delete("from s in class Simple")==2); t.commit(); s.close(); + } + + public void testMultiTableCollections() throws Exception { + Session s = sessions.openSession(); + Transaction t = s.beginTransaction(); + Multi multi = new Multi(); + multi.setExtraProp("extra"); + //multi.setCount(666); + multi.setName("name"); + Simple simp = new Simple(); + simp.setDate( new Date() ); + simp.setName("simp"); + //simp.setCount(132); + s.save( multi, new Long(123) ); + s.save( simp, new Long(1234) ); + LessSimple ls = new LessSimple(); + ls.setOther(ls); + ls.setAnother(ls); + ls.setYetanother(ls); + ls.setName("Less Simple"); + Set set = new HashSet(); + ls.setSet(set); + set.add(multi); + set.add(simp); + s.save( ls, new Long(2) ); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + ls = (LessSimple) s.load( LessSimple.class, new Long(2) ); + assertTrue( ls.getOther()==ls && ls.getAnother()==ls && ls.getYetanother()==ls ); + assertTrue( ls.getSet().size()==2 ); + Iterator iter = ls.getSet().iterator(); + int foundMulti = 0; + int foundSimple = 0; + while ( iter.hasNext() ) { + Object o = iter.next(); + if ( o instanceof Simple ) foundSimple++; + if ( o instanceof Multi ) foundMulti++; + } + assertTrue( foundSimple==2 && foundMulti==1 ); + assertTrue( s.delete("from s in class Simple")==3 ); + t.commit(); + s.close(); + } + + public void testMultiTableNativeId() throws Exception { + Session s = sessions.openSession(); + Transaction t = s.beginTransaction(); + Multi multi = new Multi(); + multi.setExtraProp("extra"); + Long id = (Long) s.save(multi); + assertTrue( id!=null ); + s.delete(multi); + t.commit(); + s.close(); } |