[hibernate-commits] Hibernate SVN: r11070 - in branches/Branch_3_2/Hibernate3: test/org/hibernate/test/component and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Sat Jan 20 14:16:38 EST 2007


Author: steve.ebersole at jboss.com
Date: 2007-01-20 14:16:38 -0500 (Sat, 20 Jan 2007)
New Revision: 11070

Modified:
   branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityUpdateAction.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/component/ComponentTest.java
Log:
HHH-2366 : changing a component property not detected as dirty

Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityUpdateAction.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityUpdateAction.java	2007-01-19 15:43:28 UTC (rev 11069)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/action/EntityUpdateAction.java	2007-01-20 19:16:38 UTC (rev 11070)
@@ -108,22 +108,26 @@
 		}
 
 		if ( entry.getStatus()==Status.MANAGED || persister.isVersionPropertyGenerated() ) {
+			// get the updated snapshot of the entity state by cloning current state;
+			// it is safe to copy in place, since by this time no-one else (should have)
+			// has a reference  to the array
+			TypeFactory.deepCopy(
+					state,
+					persister.getPropertyTypes(),
+					persister.getPropertyCheckability(),
+					state,
+					session
+			);
 			if ( persister.hasUpdateGeneratedProperties() ) {
-				// get the updated snapshot by cloning current state;
-				// it is safe to copy in place, since by this time
-				// no-one else has a reference to the array
-				TypeFactory.deepCopy(
-						state,
-						persister.getPropertyTypes(),
-						persister.getPropertyCheckability(),
-						state,
-						session
-				);
+				// this entity defines proeprty generation, so process those generated
+				// values...
 				persister.processUpdateGeneratedProperties( id, instance, state, session );
 				if ( persister.isVersionPropertyGenerated() ) {
-					nextVersion = Versioning.getVersion(state, persister);
+					nextVersion = Versioning.getVersion( state, persister );
 				}
 			}
+			// have the entity entry perform post-update processing, passing it the
+			// update state and the new version (if one).
 			entry.postUpdate( instance, state, nextVersion );
 		}
 

Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/component/ComponentTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/component/ComponentTest.java	2007-01-19 15:43:28 UTC (rev 11069)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/component/ComponentTest.java	2007-01-20 19:16:38 UTC (rev 11070)
@@ -125,6 +125,26 @@
 		s.close();
 	}
 
+	public void testComponentStateChangeAndDirtiness() {
+		// test for HHH-2366
+		Session s = openSession();
+		s.beginTransaction();
+		User u = new User( "steve", "hibernater", new Person( "Steve Ebersole", new Date(), "Main St") );
+		s.persist( u );
+		s.flush();
+		long intialUpdateCount = sfi().getStatistics().getEntityUpdateCount();
+		u.getPerson().setAddress( "Austin" );
+		s.flush();
+		assertEquals( intialUpdateCount + 1, sfi().getStatistics().getEntityUpdateCount() );
+		intialUpdateCount = sfi().getStatistics().getEntityUpdateCount();
+		u.getPerson().setAddress( "Cedar Park" );
+		s.flush();
+		assertEquals( intialUpdateCount + 1, sfi().getStatistics().getEntityUpdateCount() );
+		s.delete( u );
+		s.getTransaction().commit();
+		s.close();
+	}
+
 	public void testComponentQueries() {
 		Session s = openSession();
 		Transaction t = s.beginTransaction();




More information about the hibernate-commits mailing list