From: <one...@us...> - 2003-02-09 06:28:19
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv20713/hibernate/test Modified Files: ABC.hbm.xml ABCProxy.hbm.xml ABCProxyTest.java ABCTest.java Baz.hbm.xml Baz.java Container.hbm.xml Container.java FooBar.hbm.xml FooBarTest.java FooStatus.java Many.hbm.xml One.hbm.xml ParentChildTest.java Log Message: standardised on dom4j fixed bugs in collection caching (sometimes an exception occurred) allowed null discriminators set autocommit to true in SchemaUpdate collections now deserialize correctly Index: ABC.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ABC.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ABC.hbm.xml 28 Jan 2003 10:22:21 -0000 1.3 --- ABC.hbm.xml 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 7,15 **** <generator class="vm"/> </id> ! <discriminator column="clazz" type="integer"/> <property name="name"/> <subclass name="net.sf.hibernate.test.B" discriminator-value="-1"> <property name="count" column="count_"/> ! <subclass name="net.sf.hibernate.test.C1" discriminator-value="1"> <property name="address" column="c1"/> <one-to-one name="d"/> --- 7,15 ---- <generator class="vm"/> </id> ! <discriminator column="clazz" type="integer" not-null="false"/> <property name="name"/> <subclass name="net.sf.hibernate.test.B" discriminator-value="-1"> <property name="count" column="count_"/> ! <subclass name="net.sf.hibernate.test.C1" discriminator-value="null"> <property name="address" column="c1"/> <one-to-one name="d"/> Index: ABCProxy.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ABCProxy.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ABCProxy.hbm.xml 28 Jan 2003 10:22:21 -0000 1.3 --- ABCProxy.hbm.xml 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 9,13 **** <discriminator column="clazz" type="integer"/> <property name="name"/> ! <subclass name="net.sf.hibernate.test.B" discriminator-value="-1" proxy="net.sf.hibernate.test.B"> <property name="count" column="count_"/> <subclass name="net.sf.hibernate.test.C1" discriminator-value="1" proxy="net.sf.hibernate.test.C1"> --- 9,13 ---- <discriminator column="clazz" type="integer"/> <property name="name"/> ! <subclass name="net.sf.hibernate.test.B" discriminator-value="null" proxy="net.sf.hibernate.test.B"> <property name="count" column="count_"/> <subclass name="net.sf.hibernate.test.C1" discriminator-value="1" proxy="net.sf.hibernate.test.C1"> Index: ABCProxyTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ABCProxyTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ABCProxyTest.java 5 Jan 2003 02:11:23 -0000 1.3 --- ABCProxyTest.java 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 119,122 **** --- 119,127 ---- s.close(); + s = sessions.openSession(); + t = s.beginTransaction(); + s.find("from b in class B"); + t.commit(); + s.close(); } Index: ABCTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ABCTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ABCTest.java 5 Jan 2003 02:11:23 -0000 1.3 --- ABCTest.java 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 69,72 **** --- 69,78 ---- t.commit(); s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + s.find("from b in class B"); + t.commit(); + s.close(); } Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.hbm.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Baz.hbm.xml 2 Feb 2003 00:29:06 -0000 1.9 --- Baz.hbm.xml 9 Feb 2003 06:28:16 -0000 1.10 *************** *** 158,161 **** --- 158,180 ---- <one-to-many class = "net.sf.hibernate.test.Glarch"/> </map> + + <set name="cached" sort="natural" table="cached_set"> + <jcs-cache usage="read-write"/> + <key column="baz"/> + <composite-element class="net.sf.hibernate.test.CompositeElement"> + <property name="foo"/> + <property name="bar"/> + </composite-element> + </set> + + <map name="cachedMap" sort="natural" table="cached_map"> + <jcs-cache usage="read-write"/> + <key column="baz"/> + <index-many-to-many column="another_baz" class="net.sf.hibernate.test.Baz"/> + <composite-element class="net.sf.hibernate.test.CompositeElement"> + <property name="foo"/> + <property name="bar"/> + </composite-element> + </map> </class> Index: Baz.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Baz.java 1 Feb 2003 10:42:29 -0000 1.5 --- Baz.java 9 Feb 2003 06:28:16 -0000 1.6 *************** *** 5,9 **** import java.util.*; ! public class Baz implements Named, Serializable { private SortedSet stringSet; private Map stringDateMap; --- 5,9 ---- import java.util.*; ! public class Baz implements Named, Serializable, Comparable { private SortedSet stringSet; private Map stringDateMap; *************** *** 12,16 **** private FooProxy[] fooArray; private String[] stringArray; ! private String Code; private List customs; private List topComponents; --- 12,16 ---- private FooProxy[] fooArray; private String[] stringArray; ! private String code; private List customs; private List topComponents; *************** *** 29,32 **** --- 29,34 ---- private List fees; private Collection fooBag; + private Set cached; + private Map cachedMap; Baz() {} *************** *** 70,77 **** public String getCode() { ! return Code; } public void setCode(String code) { ! Code = code; } --- 72,79 ---- public String getCode() { ! return code; } public void setCode(String code) { ! this.code = code; } *************** *** 118,121 **** --- 120,134 ---- bag.add("duplicate"); bag.add("unique"); + cached = new TreeSet(); + CompositeElement ce = new CompositeElement(); + ce.setFoo("foo"); + ce.setBar("bar"); + CompositeElement ce2 = new CompositeElement(); + ce2.setFoo("fooxxx"); + ce2.setBar("barxxx"); + cached.add(ce); + cached.add(ce2); + cachedMap = new TreeMap(); + cachedMap.put(this, ce); } *************** *** 244,247 **** --- 257,299 ---- public void setFooBag(Collection fooBag) { this.fooBag = fooBag; + } + + /** + * Returns the cached. + * @return Set + */ + public Set getCached() { + return cached; + } + + /** + * Sets the cached. + * @param cached The cached to set + */ + public void setCached(Set cached) { + this.cached = cached; + } + + /** + * Returns the cachedMap. + * @return Map + */ + public Map getCachedMap() { + return cachedMap; + } + + /** + * Sets the cachedMap. + * @param cachedMap The cachedMap to set + */ + public void setCachedMap(Map cachedMap) { + this.cachedMap = cachedMap; + } + + /** + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(Object o) { + return ( (Baz) o ).code.compareTo(code); } Index: Container.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Container.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Container.hbm.xml 28 Jan 2003 10:22:21 -0000 1.3 --- Container.hbm.xml 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 37,40 **** --- 37,49 ---- </composite-element> </set> + <bag name="cascades" cascade="all" table="abcd"> + <key column="container_id"/> + <composite-element class="net.sf.hibernate.test.Container$ContainerInnerClass"> + <property name="name"/> + <many-to-one name="simple" cascade="all"/> + <many-to-one name="one" cascade="all" not-null="true"/> + <many-to-one name="many" cascade="all" not-null="true"/> + </composite-element> + </bag> <bag name="bag" inverse="true" cascade="save-update" table="CCBAG"> <key column="container_id"/> Index: Container.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Container.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Container.java 5 Jan 2003 02:11:23 -0000 1.3 --- Container.java 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 84,87 **** --- 84,88 ---- private List components; private Set composites; + private Collection cascades; private long id; private Collection bag; *************** *** 295,298 **** --- 296,315 ---- } + /** + * Returns the cascades. + * @return Collection + */ + public Collection getCascades() { + return cascades; + } + + /** + * Sets the cascades. + * @param cascades The cascades to set + */ + public void setCascades(Collection cascades) { + this.cascades = cascades; + } + } Index: FooBar.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBar.hbm.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FooBar.hbm.xml 2 Feb 2003 06:41:05 -0000 1.7 --- FooBar.hbm.xml 9 Feb 2003 06:28:16 -0000 1.8 *************** *** 3,7 **** <hibernate-mapping> - <class name="net.sf.hibernate.test.Foo" --- 3,6 ---- *************** *** 99,103 **** name="net.sf.hibernate.test.Abstract" proxy="net.sf.hibernate.test.AbstractProxy" ! discriminator-value="A"> <set name="abstracts"> <key column="abstract_id"/> --- 98,102 ---- name="net.sf.hibernate.test.Abstract" proxy="net.sf.hibernate.test.AbstractProxy" ! discriminator-value="null"> <set name="abstracts"> <key column="abstract_id"/> Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** FooBarTest.java 3 Feb 2003 10:28:47 -0000 1.19 --- FooBarTest.java 9 Feb 2003 06:28:16 -0000 1.20 *************** *** 130,133 **** --- 130,156 ---- } + public void testCollectionCache() throws Exception { + Session s = sessions.openSession(); + Baz baz = new Baz(); + baz.setDefaults(); + s.save(baz); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + s.load( Baz.class, baz.getCode() ); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + baz = (Baz) s.load( Baz.class, baz.getCode() ); + s.delete(baz); + s.flush(); + s.connection().commit(); + s.close(); + } + public void testAssociationId() throws Exception { Session s = sessions.openSession(); *************** *** 1987,1991 **** assertTrue( binder.toDOM()!=null, "dom" ); assertTrue( binder.toGenericDOM()!=null, "generic dom" ); ! s.delete(foo); s.delete(baz); --- 2010,2014 ---- assertTrue( binder.toDOM()!=null, "dom" ); assertTrue( binder.toGenericDOM()!=null, "generic dom" ); ! s.delete(foo); s.delete(baz); Index: FooStatus.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooStatus.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FooStatus.java 5 Jan 2003 02:11:23 -0000 1.3 --- FooStatus.java 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 28,32 **** } ! Object readResolve() { return fromInt(code); } --- 28,32 ---- } ! private Object readResolve() { return fromInt(code); } Index: Many.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Many.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Many.hbm.xml 28 Jan 2003 10:22:21 -0000 1.3 --- Many.hbm.xml 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 5,10 **** <hibernate-mapping> <class name="net.sf.hibernate.test.Many" table="many"> ! <id name="key" column="many_key"> ! <generator class="hilo" /> </id> <many-to-one name="one" column="one_key" class="net.sf.hibernate.test.One"/> --- 5,10 ---- <hibernate-mapping> <class name="net.sf.hibernate.test.Many" table="many"> ! <id name="key" column="many_key" unsaved-value="0"> ! <generator class="native" /> </id> <many-to-one name="one" column="one_key" class="net.sf.hibernate.test.One"/> Index: One.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/One.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** One.hbm.xml 28 Jan 2003 10:22:21 -0000 1.3 --- One.hbm.xml 9 Feb 2003 06:28:16 -0000 1.4 *************** *** 5,10 **** <hibernate-mapping> <class name="net.sf.hibernate.test.One" table="one"> ! <id name="key" column="one_key"> ! <generator class="hilo" /> </id> <property column="one_value" name="value"/> --- 5,10 ---- <hibernate-mapping> <class name="net.sf.hibernate.test.One" table="one"> ! <id name="key" column="one_key" unsaved-value="0"> ! <generator class="native" /> </id> <property column="one_value" name="value"/> Index: ParentChildTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ParentChildTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ParentChildTest.java 12 Jan 2003 14:45:38 -0000 1.4 --- ParentChildTest.java 9 Feb 2003 06:28:16 -0000 1.5 *************** *** 345,348 **** --- 345,394 ---- } + public void testCascadeCompositeElements() throws Exception { + Container c = new Container(); + List list = new ArrayList(); + c.setCascades(list); + Container.ContainerInnerClass cic = new Container.ContainerInnerClass(); + cic.setMany( new Many() ); + cic.setOne( new One() ); + list.add(cic); + Session s = sessions.openSession(); + s.save(c); + s.flush(); + s.connection().commit(); + s.close(); + s=sessions.openSession(); + c = (Container) s.iterate("from c in class Container").next(); + cic = (Container.ContainerInnerClass) c.getCascades().iterator().next(); + assertTrue( cic.getMany()!=null && cic.getOne()!=null ); + assertTrue( c.getCascades().size()==1 ); + s.delete(c); + s.flush(); + s.connection().commit(); + s.close(); + + c = new Container(); + s = sessions.openSession(); + s.save(c); + list = new ArrayList(); + c.setCascades(list); + cic = new Container.ContainerInnerClass(); + cic.setMany( new Many() ); + cic.setOne( new One() ); + list.add(cic); + s.flush(); + s.connection().commit(); + s.close(); + s=sessions.openSession(); + c = (Container) s.iterate("from c in class Container").next(); + cic = (Container.ContainerInnerClass) c.getCascades().iterator().next(); + assertTrue( cic.getMany()!=null && cic.getOne()!=null ); + assertTrue( c.getCascades().size()==1 ); + s.delete(c); + s.flush(); + s.connection().commit(); + s.close(); + } + public void testBag() throws Exception { Session s = sessions.openSession(); |