From: <one...@us...> - 2003-05-02 09:22:03
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv20532/test Modified Files: Baz.hbm.xml Baz.java FooBarTest.java Log Message: added idbag and made some cleanups to collection fwk Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.hbm.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Baz.hbm.xml 18 Apr 2003 05:09:51 -0000 1.18 --- Baz.hbm.xml 2 May 2003 09:21:59 -0000 1.19 *************** *** 89,98 **** <set name="stringSet" lazy="true" sort="natural"> <!--<jcs-cache usage="read-write"/>--> ! <key column="id_" /> <element column="element" type="string" not-null="true" length="32"/> </set> <map name="stringDateMap" lazy="true" sort="net.sf.hibernate.test.ReverseComparator"> ! <key column="id_" /> <index column="map_key" type="string" length="32"/> <element column="map_value" type="date"/> --- 89,98 ---- <set name="stringSet" lazy="true" sort="natural"> <!--<jcs-cache usage="read-write"/>--> ! <key column="id_"/> <element column="element" type="string" not-null="true" length="32"/> </set> <map name="stringDateMap" lazy="true" sort="net.sf.hibernate.test.ReverseComparator"> ! <key column="id_"/> <index column="map_key" type="string" length="32"/> <element column="map_value" type="date"/> *************** *** 101,105 **** <array name="fooArray" element-class="net.sf.hibernate.test.FooProxy" where="i<8"> <jcs-cache usage="read-write"/> ! <key column="id_" /> <index column="i"/> <many-to-many class="net.sf.hibernate.test.Foo"> --- 101,105 ---- <array name="fooArray" element-class="net.sf.hibernate.test.FooProxy" where="i<8"> <jcs-cache usage="read-write"/> ! <key column="id_"/> <index column="i"/> <many-to-many class="net.sf.hibernate.test.Foo"> *************** *** 109,118 **** <bag name="fooBag" lazy="true" table="baz_foo" cascade="all"> ! <key column="baz" /> <many-to-many class="net.sf.hibernate.test.Foo" column="foo" outer-join="true"/> </bag> <array name="stringArray"> ! <key column="id_" /> <index column="i"/> <element column="name" type="string"/> --- 109,134 ---- <bag name="fooBag" lazy="true" table="baz_foo" cascade="all"> ! <key column="baz"/> <many-to-many class="net.sf.hibernate.test.Foo" column="foo" outer-join="true"/> </bag> + <idbag name="idFooBag" lazy="true" table="baz_id_foo" cascade="all"> + <collection-id column="pkid" type="long"> + <generator class="hilo"/> + </collection-id> + <key column="baz"/> + <many-to-many class="net.sf.hibernate.test.Foo" column="foo" outer-join="true"/> + </idbag> + + <idbag name="byteBag" lazy="true" table="baz_byte_bag" cascade="all"> + <collection-id column="pkid" type="long"> + <generator class="hilo"/> + </collection-id> + <key column="baz"/> + <element type="binary" column="bytez" not-null="true"/> + </idbag> + <array name="stringArray"> ! <key column="id_"/> <index column="i"/> <element column="name" type="string"/> Index: Baz.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Baz.java 5 Apr 2003 07:13:38 -0000 1.9 --- Baz.java 2 May 2003 09:21:59 -0000 1.10 *************** *** 42,45 **** --- 42,47 ---- private Map stringGlarchMap; private Map anyToAny; + private Collection idFooBag; + private Collection byteBag; Baz() {} *************** *** 339,342 **** --- 341,360 ---- public void setAnyToAny(Map anyToAny) { this.anyToAny = anyToAny; + } + + public Collection getIdFooBag() { + return idFooBag; + } + + public void setIdFooBag(Collection collection) { + idFooBag = collection; + } + + public Collection getByteBag() { + return byteBag; + } + + public void setByteBag(Collection list) { + byteBag = list; } Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** FooBarTest.java 25 Apr 2003 03:40:36 -0000 1.59 --- FooBarTest.java 2 May 2003 09:21:59 -0000 1.60 *************** *** 59,62 **** --- 59,110 ---- } + public void testIdBag() throws Exception { + Session s = sessions.openSession(); + Baz baz = new Baz(); + s.save(baz); + List l = new ArrayList(); + List l2 = new ArrayList(); + baz.setIdFooBag(l); + baz.setByteBag(l2); + l.add( new Foo() ); + l.add( new Bar() ); + byte[] bytes = "ffo".getBytes(); + l2.add(bytes); + l2.add( "foo".getBytes() ); + s.flush(); + l.add( new Foo() ); + l.add( new Bar() ); + l2.add( "bar".getBytes() ); + s.flush(); + s.delete( l.remove(3) ); + bytes[1]='o'; + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + baz = (Baz) s.load(Baz.class, baz.getCode()); + assertTrue( baz.getIdFooBag().size()==3 ); + assertTrue( baz.getByteBag().size()==3 ); + bytes = "foobar".getBytes(); + Iterator iter = baz.getIdFooBag().iterator(); + while ( iter.hasNext() ) s.delete( iter.next() ); + baz.setIdFooBag(null); + baz.getByteBag().add(bytes); + baz.getByteBag().add(bytes); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + baz = (Baz) s.load(Baz.class, baz.getCode()); + assertTrue( baz.getIdFooBag().size()==0 ); + assertTrue( baz.getByteBag().size()==5 ); + s.delete(baz); + s.flush(); + s.connection().commit(); + s.close(); + } + public void testForceOuterJoin() throws Exception { Session s = sessions.openSession(); |