From: <one...@us...> - 2002-12-07 09:41:26
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv16209/cirrus/hibernate/test Modified Files: Contained.java Container.hbm.xml Container.java ParentChildTest.java Log Message: added a test for initialize-after-add Index: Contained.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Contained.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Contained.java 26 Nov 2002 03:35:44 -0000 1.3 --- Contained.java 7 Dec 2002 09:41:22 -0000 1.4 *************** *** 9,12 **** --- 9,14 ---- private long id; private Collection bag = new ArrayList(); + private Collection lazyBag = new ArrayList(); + public boolean equals(Object other) { return id==( (Contained) other ).id; *************** *** 62,65 **** --- 64,83 ---- public void setBag(Collection bag) { this.bag = bag; + } + + /** + * Returns the lazyBag. + * @return Collection + */ + public Collection getLazyBag() { + return lazyBag; + } + + /** + * Sets the lazyBag. + * @param lazyBag The lazyBag to set + */ + public void setLazyBag(Collection lazyBag) { + this.lazyBag = lazyBag; } Index: Container.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Container.hbm.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Container.hbm.xml 20 Nov 2002 14:20:09 -0000 1.10 --- Container.hbm.xml 7 Dec 2002 09:41:22 -0000 1.11 *************** *** 41,44 **** --- 41,48 ---- <many-to-many column="contained_id" class="cirrus.hibernate.test.Contained" outer-join="true"/> </bag> + <bag role="lazyBag" readonly="true" lazy="true" table="LCCBAG"> + <key column="container_id"/> + <many-to-many column="contained_id" class="cirrus.hibernate.test.Contained"/> + </bag> <map role="ternaryMap"> <key column="container_id"/> *************** *** 67,70 **** --- 71,78 ---- <key column="contained_id"/> <many-to-many column="container_id" class="cirrus.hibernate.test.Container" outer-join="false"/> + </bag> + <bag role="lazyBag" lazy="true" table="LCCBAG"> + <key column="contained_id"/> + <many-to-many column="container_id" class="cirrus.hibernate.test.Container"/> </bag> </class> Index: Container.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Container.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Container.java 4 Oct 2002 17:50:21 -0000 1.4 --- Container.java 7 Dec 2002 09:41:22 -0000 1.5 *************** *** 2,5 **** --- 2,6 ---- package cirrus.hibernate.test; + import java.util.ArrayList; import java.util.Collection; import java.util.List; *************** *** 85,88 **** --- 86,90 ---- private long id; private Collection bag; + private Collection lazyBag = new ArrayList(); private Map ternaryMap; private Set ternarySet; *************** *** 275,278 **** --- 277,296 ---- public void setTernarySet(Set ternarySet) { this.ternarySet = ternarySet; + } + + /** + * Returns the lazyBag. + * @return Collection + */ + public Collection getLazyBag() { + return lazyBag; + } + + /** + * Sets the lazyBag. + * @param lazyBag The lazyBag to set + */ + public void setLazyBag(Collection lazyBag) { + this.lazyBag = lazyBag; } Index: ParentChildTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/ParentChildTest.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ParentChildTest.java 26 Nov 2002 03:35:44 -0000 1.31 --- ParentChildTest.java 7 Dec 2002 09:41:22 -0000 1.32 *************** *** 343,346 **** --- 343,369 ---- c.getBag().add(c2); c2.getBag().add(c); + c.getLazyBag().add(c1); + c1.getLazyBag().add(c); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + c = (Container) s.find("from c in class Container").get(0); + Contained c3 = new Contained(); + c.getBag().add(c3); + c3.getBag().add(c); + c.getLazyBag().add(c3); + c3.getLazyBag().add(c); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + c = (Container) s.find("from c in class Container").get(0); + Contained c4 = new Contained(); + c.getLazyBag().add(c4); + c4.getLazyBag().add(c); + assertTrue( c.getLazyBag().size()==3 ); t.commit(); s.close(); *************** *** 355,359 **** j++; } ! assertTrue(j==3); s.delete(c); c.getBag().remove(c2); --- 378,382 ---- j++; } ! assertTrue(j==4); s.delete(c); c.getBag().remove(c2); *************** *** 364,368 **** s.delete( iter.next() ); } ! assertTrue(j==2); t.commit(); s.close(); --- 387,392 ---- s.delete( iter.next() ); } ! assertTrue(j==3); ! s.delete( s.load(Contained.class, new Long( c4.getId() ) ) ); t.commit(); s.close(); |