From: <one...@us...> - 2003-04-04 13:52:05
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv7478/hibernate/test Modified Files: Baz.hbm.xml FooBarTest.java FooComponent.java Log Message: added NonstrictReadWriteCache fixed problem with proxy.getId() for an interface proxy Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.hbm.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Baz.hbm.xml 2 Apr 2003 13:10:37 -0000 1.15 --- Baz.hbm.xml 4 Apr 2003 13:51:59 -0000 1.16 *************** *** 69,72 **** --- 69,73 ---- </map> <map name="fooComponentToFoo"> + <jcs-cache usage="read-write"/> <key> <column name="baz_id" length="16"/> Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** FooBarTest.java 3 Apr 2003 12:34:29 -0000 1.46 --- FooBarTest.java 4 Apr 2003 13:51:59 -0000 1.47 *************** *** 687,690 **** --- 687,691 ---- map = new HashMap(); map.put( new FooComponent("name", 123, null, null), bar ); + map.put( new FooComponent("nameName", 12, null, null), bar ); baz.setFooComponentToFoo(map); map = new HashMap(); *************** *** 696,699 **** --- 697,708 ---- s = sessions.openSession(); baz = (Baz) s.find("select baz from baz in class net.sf.hibernate.test.Baz order by baz").get(0); + Session s2 = sessions.openSession(); + baz = (Baz) s.find("select baz from baz in class net.sf.hibernate.test.Baz order by baz").get(0); + Object o = baz.getFooComponentToFoo().get(new FooComponent("name", 123, null, null)); + assertTrue( + o==baz.getFooComponentToFoo().get(new FooComponent("nameName", 12, null, null)) && o!=null + ); + s2.connection().commit(); + s2.close(); assertTrue( baz.getTopFoos().size()==2 ); assertTrue( baz.getTopGlarchez().size()==1 ); *************** *** 702,711 **** assertTrue( baz.getBag().size()==4 ); assertTrue( baz.getFooToGlarch().size()==2 ); ! assertTrue( baz.getFooComponentToFoo().size()==1 ); assertTrue( baz.getGlarchToFoo().size()==1 ); Iterator iter = baz.getFooToGlarch().keySet().iterator(); for (int i=0; i<2; i++ ) assertTrue( iter.next() instanceof BarProxy ); FooComponent fooComp = (FooComponent) baz.getFooComponentToFoo().keySet().iterator().next(); ! assertTrue( fooComp.getCount()==123 && fooComp.getName().equals("name") && ( baz.getFooComponentToFoo().get(fooComp) instanceof BarProxy ) ); Glarch g2 = new Glarch(); s.save(g2); --- 711,724 ---- assertTrue( baz.getBag().size()==4 ); assertTrue( baz.getFooToGlarch().size()==2 ); ! assertTrue( baz.getFooComponentToFoo().size()==2 ); assertTrue( baz.getGlarchToFoo().size()==1 ); Iterator iter = baz.getFooToGlarch().keySet().iterator(); for (int i=0; i<2; i++ ) assertTrue( iter.next() instanceof BarProxy ); FooComponent fooComp = (FooComponent) baz.getFooComponentToFoo().keySet().iterator().next(); ! assertTrue( ! ( (fooComp.getCount()==123 && fooComp.getName().equals("name")) ! || (fooComp.getCount()==12 && fooComp.getName().equals("nameName")) ) ! && ( baz.getFooComponentToFoo().get(fooComp) instanceof BarProxy ) ! ); Glarch g2 = new Glarch(); s.save(g2); *************** *** 904,907 **** --- 917,924 ---- q = (Qux) s.load(Qux.class, q.getKey() ); b = (BarProxy) s.load( Foo.class, b.getKey() ); + b.getKey(); + assertFalse( Hibernate.isInitialized(b) ); + b.getBarString(); + assertTrue( Hibernate.isInitialized(b) ); BarProxy b2 = (BarProxy) s.load( Bar.class, new String( b.getKey() ) ); Qux q2 = (Qux) s.load( Qux.class, q.getKey() ); Index: FooComponent.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooComponent.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FooComponent.java 3 Feb 2003 10:28:47 -0000 1.5 --- FooComponent.java 4 Apr 2003 13:52:00 -0000 1.6 *************** *** 15,18 **** --- 15,27 ---- private Baz baz; + public boolean equals(Object that) { + FooComponent fc = (FooComponent) that; + return count==fc.count; + } + + public int hashCode() { + return count; + } + public String toString() { String result = "FooComponent: " + name + "=" + count; |