From: <one...@us...> - 2003-04-15 04:19:20
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv25173/hibernate/test Modified Files: Circular.hbm.xml FooBarTest.java Glarch.hbm.xml Glarch.java GlarchProxy.java Multiplicity.java MultiplicityType.java ParentChildTest.java Added Files: Super.java Log Message: fixed 2 problems with proxies * interface proxies were not being used properly * some method invocations were not being properly proxied --- NEW FILE: Super.java --- package net.sf.hibernate.test; public class Super { protected String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } Index: Circular.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Circular.hbm.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Circular.hbm.xml 29 Mar 2003 07:36:22 -0000 1.4 --- Circular.hbm.xml 15 Apr 2003 04:19:17 -0000 1.5 *************** *** 3,7 **** <hibernate-mapping default-cascade="save-update"> ! <class name="net.sf.hibernate.test.Circular"> <id name="id" column="id_" length="64" unsaved-value="null"> <generator class="uuid.hex"/> --- 3,7 ---- <hibernate-mapping default-cascade="save-update"> ! <class name="net.sf.hibernate.test.Circular" dynamic-update="true"> <id name="id" column="id_" length="64" unsaved-value="null"> <generator class="uuid.hex"/> Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** FooBarTest.java 8 Apr 2003 14:07:09 -0000 1.52 --- FooBarTest.java 15 Apr 2003 04:19:17 -0000 1.53 *************** *** 124,131 **** public void testCustom() throws Exception { ! Glarch g = new Glarch(); Multiplicity m = new Multiplicity(); m.count = 12; ! m.glarch = g; g.setMultiple(m); Session s = sessions.openSession(); --- 124,131 ---- public void testCustom() throws Exception { ! GlarchProxy g = new Glarch(); Multiplicity m = new Multiplicity(); m.count = 12; ! m.glarch = (Glarch) g; g.setMultiple(m); Session s = sessions.openSession(); *************** *** 145,149 **** s = sessions.openSession(); ! g = (Glarch) s.load(Glarch.class, gid); assertTrue( g.getMultiple()!=null ); assertEquals( g.getMultiple().count, 12 ); --- 145,149 ---- s = sessions.openSession(); ! g = (GlarchProxy) s.load(Glarch.class, gid); assertTrue( g.getMultiple()!=null ); assertEquals( g.getMultiple().count, 12 ); *************** *** 203,206 **** --- 203,207 ---- Session s = sessions.openSession(); GlarchProxy g = new Glarch(); + g.setName("G"); Serializable id = s.save(g); s.flush(); *************** *** 210,214 **** --- 211,217 ---- s = sessions.openSession(); g = (GlarchProxy) s.load(Glarch.class, id); + assertTrue( ( (Super) g ).getName().equals("G") ); assertTrue( g.getDynaBean().get("foo").equals("foo") && g.getDynaBean().get("bar").equals( new Integer(66) ) ); + //assertTrue( ! (g instanceof Glarch) ); g.getDynaBean().set("foo", "bar"); s.flush(); *************** *** 328,332 **** Session s = sessions.openSession(); Transaction t = s.beginTransaction(); ! Bar bar = new Bar(); bar.setBarComponent( new FooComponent() ); Baz baz = new Baz(); --- 331,335 ---- Session s = sessions.openSession(); Transaction t = s.beginTransaction(); ! BarProxy bar = new Bar(); bar.setBarComponent( new FooComponent() ); Baz baz = new Baz(); *************** *** 338,342 **** s = sessions.openSession(); t = s.beginTransaction(); ! bar = (Bar) s.load(Bar.class, bar.getKey()); s.load(baz, baz.getCode()); assertTrue( bar.getBarComponent().getParent()==bar ); --- 341,345 ---- s = sessions.openSession(); t = s.beginTransaction(); ! bar = (BarProxy) s.load(Bar.class, bar.getKey()); s.load(baz, baz.getCode()); assertTrue( bar.getBarComponent().getParent()==bar ); *************** *** 2844,2848 **** err=false; try { ! ( (Foo) s.load(Foo.class, id) ).getBool(); } catch (LazyInitializationException onfe) { --- 2847,2851 ---- err=false; try { ! ( (FooProxy) s.load(Foo.class, id) ).getBool(); } catch (LazyInitializationException onfe) { *************** *** 2878,2882 **** public void testObjectType() throws Exception { Session s = sessions.openSession(); ! Glarch g = new Glarch(); Foo foo = new Foo(); g.setAny(foo); --- 2881,2885 ---- public void testObjectType() throws Exception { Session s = sessions.openSession(); ! GlarchProxy g = new Glarch(); Foo foo = new Foo(); g.setAny(foo); *************** *** 2887,2892 **** s.close(); s = sessions.openSession(); ! g = (Glarch) s.load(Glarch.class, gid); ! assertTrue( g.getAny()!=null && g.getAny() instanceof Foo ); s.delete( g.getAny() ); s.delete(g); --- 2890,2895 ---- s.close(); s = sessions.openSession(); ! g = (GlarchProxy) s.load(Glarch.class, gid); ! assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy ); s.delete( g.getAny() ); s.delete(g); Index: Glarch.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Glarch.hbm.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Glarch.hbm.xml 6 Apr 2003 10:11:11 -0000 1.12 --- Glarch.hbm.xml 15 Apr 2003 04:19:17 -0000 1.13 *************** *** 5,9 **** <class name="net.sf.hibernate.test.Glarch" table="glarchez" ! proxy="net.sf.hibernate.test.GlarchProxy" dynamic-update="true"> <!--<jcs-cache usage="read-write"/>--> --- 5,9 ---- <class name="net.sf.hibernate.test.Glarch" table="glarchez" ! proxy="net.sf.hibernate.test.Glarch" dynamic-update="true"> <!--<jcs-cache usage="read-write"/>--> Index: Glarch.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Glarch.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Glarch.java 6 Apr 2003 10:11:11 -0000 1.9 --- Glarch.java 15 Apr 2003 04:19:17 -0000 1.10 *************** *** 17,24 **** import org.apache.commons.beanutils.BasicDynaClass; ! public class Glarch implements GlarchProxy, Lifecycle, Named, Serializable { private int version; - private String name; private GlarchProxy next; private short order; --- 17,23 ---- import org.apache.commons.beanutils.BasicDynaClass; ! public class Glarch extends Super implements GlarchProxy, Lifecycle, Named, Serializable { private int version; private GlarchProxy next; private short order; *************** *** 49,59 **** public void setVersion(int version) { this.version = version; - } - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; } --- 48,51 ---- Index: GlarchProxy.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/GlarchProxy.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GlarchProxy.java 28 Jan 2003 10:22:21 -0000 1.5 --- GlarchProxy.java 15 Apr 2003 04:19:17 -0000 1.6 *************** *** 39,42 **** --- 39,48 ---- public Set getProxySet(); public void setProxySet(Set proxySet); + + public Multiplicity getMultiple(); + public void setMultiple(Multiplicity m); + + public Object getAny(); + public void setAny(Object any); } Index: Multiplicity.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Multiplicity.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Multiplicity.java 6 Apr 2003 10:16:49 -0000 1.1 --- Multiplicity.java 15 Apr 2003 04:19:17 -0000 1.2 *************** *** 5,8 **** public class Multiplicity implements Serializable { public int count; ! public Glarch glarch; } --- 5,8 ---- public class Multiplicity implements Serializable { public int count; ! public GlarchProxy glarch; } Index: MultiplicityType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MultiplicityType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MultiplicityType.java 6 Apr 2003 10:16:50 -0000 1.1 --- MultiplicityType.java 15 Apr 2003 04:19:17 -0000 1.2 *************** *** 73,77 **** Integer c = (Integer) Hibernate.INTEGER.nullSafeGet( rs, names[0] ); ! Glarch g = (Glarch) Hibernate.association(Glarch.class).nullSafeGet(rs, names[1], session, owner); Multiplicity m = new Multiplicity(); m.count = c==null ? 0 : c.intValue(); --- 73,77 ---- Integer c = (Integer) Hibernate.INTEGER.nullSafeGet( rs, names[0] ); ! GlarchProxy g = (GlarchProxy) Hibernate.association(Glarch.class).nullSafeGet(rs, names[1], session, owner); Multiplicity m = new Multiplicity(); m.count = c==null ? 0 : c.intValue(); *************** *** 84,88 **** Multiplicity o = (Multiplicity) value; ! Glarch g; Integer c; if (o==null) { --- 84,88 ---- Multiplicity o = (Multiplicity) value; ! GlarchProxy g; Integer c; if (o==null) { Index: ParentChildTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ParentChildTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ParentChildTest.java 2 Apr 2003 13:10:39 -0000 1.9 --- ParentChildTest.java 15 Apr 2003 04:19:17 -0000 1.10 *************** *** 606,610 **** s = sessions.openSession(); g = (Parent) s.load( Parent.class, new Long( g.getId() ) ); ! assertTrue( g.getAny()!=null && g.getAny() instanceof Foo ); s.delete( g.getAny() ); s.delete(g); --- 606,610 ---- s = sessions.openSession(); g = (Parent) s.load( Parent.class, new Long( g.getId() ) ); ! assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy ); s.delete( g.getAny() ); s.delete(g); |