From: <one...@us...> - 2003-02-03 10:28:51
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv20343/hibernate/test Modified Files: FooBarTest.java FooComponent.java Log Message: added warning in custom type made <parent> proxy-aware Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** FooBarTest.java 1 Feb 2003 10:42:29 -0000 1.18 --- FooBarTest.java 3 Feb 2003 10:28:47 -0000 1.19 *************** *** 107,110 **** --- 107,133 ---- } + public void testComponentParent() throws Exception { + Session s = sessions.openSession(); + Transaction t = s.beginTransaction(); + Bar bar = new Bar(); + bar.setBarComponent( new FooComponent() ); + Baz baz = new Baz(); + baz.setComponents( new FooComponent[] { new FooComponent(), new FooComponent() } ); + s.save(bar); + s.save(baz); + t.commit(); + s.close(); + s = sessions.openSession(); + t = s.beginTransaction(); + bar = (Bar) s.load(Bar.class, bar.getKey()); + s.load(baz, baz.getCode()); + assertTrue( bar.getBarComponent().getParent()==bar ); + assertTrue( baz.getComponents()[0].getBaz()==baz && baz.getComponents()[1].getBaz()==baz ); + s.delete(baz); + s.delete(bar); + t.commit(); + s.close(); + } + public void testAssociationId() throws Exception { Session s = sessions.openSession(); Index: FooComponent.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooComponent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FooComponent.java 5 Jan 2003 02:11:23 -0000 1.4 --- FooComponent.java 3 Feb 2003 10:28:47 -0000 1.5 *************** *** 12,16 **** Fee fee = new Fee(); GlarchProxy glarch; ! private Foo parent; private Baz baz; --- 12,16 ---- Fee fee = new Fee(); GlarchProxy glarch; ! private FooProxy parent; private Baz baz; *************** *** 97,105 **** } ! public Foo getParent() { return parent; } ! public void setParent(Foo parent) { this.parent = parent; } --- 97,106 ---- } ! public FooProxy getParent() { return parent; } ! public void setParent(FooProxy parent) { ! if (parent==null) throw new RuntimeException("null parent set"); this.parent = parent; } |