[hibernate-commits] Hibernate SVN: r10292 - in trunk/Hibernate3/test/org/hibernate/test/instrument: cases domain runtime
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Fri Aug 18 17:54:55 EDT 2006
Author: steve.ebersole at jboss.com
Date: 2006-08-18 17:53:53 -0400 (Fri, 18 Aug 2006)
New Revision: 10292
Modified:
trunk/Hibernate3/test/org/hibernate/test/instrument/cases/TestManyToOneProxyExecutable.java
trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Entity.java
trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java
Log:
expanded many-to-one proxy test case
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/cases/TestManyToOneProxyExecutable.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/cases/TestManyToOneProxyExecutable.java 2006-08-18 21:52:34 UTC (rev 10291)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/cases/TestManyToOneProxyExecutable.java 2006-08-18 21:53:53 UTC (rev 10292)
@@ -14,23 +14,53 @@
public void execute() {
Session s = getFactory().openSession();
Transaction t = s.beginTransaction();
- Entity parent = new Entity( "parent" );
- s.save( parent );
- Entity child = new Entity( "child", parent );
- s.save( child );
+ Entity root = new Entity( "root" );
+ Entity child1 = new Entity( "child1" );
+ Entity child2 = new Entity( "child2" );
+ root.setChild( child1 );
+ child1.setSibling( child2 );
+ Entity gChild1 = new Entity( "grandchild 1" );
+ Entity gChild2 = new Entity( "grandchild 2" );
+ child1.setChild( gChild1 );
+ gChild1.setSibling( gChild2 );
+ s.save( root );
t.commit();
s.close();
+ // NOTE : child is mapped with lazy="proxy"; sibling with lazy="no-proxy"...
+
s = getFactory().openSession();
t = s.beginTransaction();
- child = ( Entity ) s.get( Entity.class, child.getId() );
- Assert.assertFalse( Hibernate.isPropertyInitialized( child, "name" ) );
- Assert.assertTrue( Hibernate.isPropertyInitialized( child, "parent" ) );
- parent = child.getParent();
- Assert.assertFalse( Hibernate.isPropertyInitialized( parent, "name" ) );
- Assert.assertFalse( Hibernate.isPropertyInitialized( child, "name" ) );
- s.delete( child );
- s.delete( parent );
+ // load root
+ root = ( Entity ) s.get( Entity.class, root.getId() );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( root, "name" ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( root, "sibling" ) );
+ Assert.assertTrue( Hibernate.isPropertyInitialized( root, "child" ) );
+
+ // get a handle to the child1 proxy reference (and make certain that
+ // this does not force the lazy properties of the root entity
+ // to get initialized.
+ child1 = root.getChild();
+ Assert.assertFalse( Hibernate.isInitialized( child1 ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( root, "name" ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( root, "sibling" ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( child1, "name" ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( child1, "sibling" ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( child1, "child" ) );
+
+ child1.getName();
+ Assert.assertFalse( Hibernate.isPropertyInitialized( root, "name" ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( root, "sibling" ) );
+ Assert.assertTrue( Hibernate.isPropertyInitialized( child1, "name" ) );
+ Assert.assertTrue( Hibernate.isPropertyInitialized( child1, "sibling" ) );
+ Assert.assertTrue( Hibernate.isPropertyInitialized( child1, "child" ) );
+
+ gChild1 = child1.getChild();
+ Assert.assertFalse( Hibernate.isInitialized( gChild1 ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( root, "name" ) );
+ Assert.assertFalse( Hibernate.isPropertyInitialized( root, "sibling" ) );
+
+ s.delete( root );
t.commit();
s.close();
}
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml 2006-08-18 21:52:34 UTC (rev 10291)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Documents.hbm.xml 2006-08-18 21:53:53 UTC (rev 10292)
@@ -68,7 +68,8 @@
<generator class="increment"/>
</id>
<property name="name" column="NAME" type="string" lazy="true"/>
- <many-to-one name="parent" column="PRNT_ID" class="Entity" lazy="proxy"/>
+ <many-to-one name="child" column="PRNT_ID" class="Entity" lazy="proxy" cascade="all" />
+ <many-to-one name="sibling" column="RIGHT_ID" class="Entity" lazy="no-proxy" cascade="all" />
</class>
</hibernate-mapping>
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Entity.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Entity.java 2006-08-18 21:52:34 UTC (rev 10291)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/domain/Entity.java 2006-08-18 21:53:53 UTC (rev 10292)
@@ -8,7 +8,8 @@
public class Entity {
private Long id;
private String name;
- private Entity parent;
+ private Entity child;
+ private Entity sibling;
public Entity() {
}
@@ -17,15 +18,14 @@
this.name = name;
}
- public Entity(String name, Entity parent) {
- this.name = name;
- this.parent = parent;
- }
-
public Long getId() {
return id;
}
+ public void setId(Long id) {
+ this.id = id;
+ }
+
public String getName() {
return name;
}
@@ -34,11 +34,19 @@
this.name = name;
}
- public Entity getParent() {
- return parent;
+ public Entity getChild() {
+ return child;
}
- public void setParent(Entity parent) {
- this.parent = parent;
+ public void setChild(Entity child) {
+ this.child = child;
}
+
+ public Entity getSibling() {
+ return sibling;
+ }
+
+ public void setSibling(Entity sibling) {
+ this.sibling = sibling;
+ }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java 2006-08-18 21:52:34 UTC (rev 10291)
+++ trunk/Hibernate3/test/org/hibernate/test/instrument/runtime/CGLIBInstrumentationTest.java 2006-08-18 21:53:53 UTC (rev 10292)
@@ -16,4 +16,32 @@
public static Test suite() {
return new TestSuite( CGLIBInstrumentationTest.class );
}
+
+ public void testSetFieldInterceptor() {
+ super.testSetFieldInterceptor(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testDirtyCheck() {
+ super.testDirtyCheck(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testFetchAll() throws Exception {
+ super.testFetchAll(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testLazy() {
+ super.testLazy(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testLazyManyToOne() {
+ super.testLazyManyToOne(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testPropertyInitialized() {
+ super.testPropertyInitialized(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void testManyToOneProxy() {
+ super.testManyToOneProxy(); //To change body of overridden methods use File | Settings | File Templates.
+ }
}
More information about the hibernate-commits
mailing list