[hibernate-commits] Hibernate SVN: r18511 - core/trunk/testsuite/src/test/java/org/hibernate/test/readonly.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Jan 12 03:15:15 EST 2010


Author: gbadner
Date: 2010-01-12 03:15:15 -0500 (Tue, 12 Jan 2010)
New Revision: 18511

Modified:
   core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java
Log:
HHH-4781 : Added unit test showing a read-only entity that is refreshed is changed to modifiable

Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java	2010-01-12 01:16:55 UTC (rev 18510)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java	2010-01-12 08:15:15 UTC (rev 18511)
@@ -141,6 +141,43 @@
 		
 	}
 
+	public void testReadOnlyRefreshFailureExpected() {
+
+		Session s = openSession();
+		s.setCacheMode(CacheMode.IGNORE);
+		Transaction t = s.beginTransaction();
+		DataPoint dp = new DataPoint();
+		dp.setDescription( "original" );
+		dp.setX( new BigDecimal(0.1d).setScale(19, BigDecimal.ROUND_DOWN) );
+		dp.setY( new BigDecimal( Math.cos( dp.getX().doubleValue() ) ).setScale(19, BigDecimal.ROUND_DOWN) );
+		s.save(dp);
+		t.commit();
+		s.close();
+
+		s = openSession();
+		s.setCacheMode(CacheMode.IGNORE);
+		t = s.beginTransaction();
+		dp = ( DataPoint ) s.get( DataPoint.class, dp.getId() );
+		s.setReadOnly( dp, true );
+		assertEquals( "original", dp.getDescription() );
+		dp.setDescription( "changed" );
+		assertEquals( "changed", dp.getDescription() );
+		s.refresh( dp );
+		assertEquals( "original", dp.getDescription() );
+		dp.setDescription( "changed" );
+		assertEquals( "changed", dp.getDescription() );
+		t.commit();
+
+		s.clear();
+		t = s.beginTransaction();
+		dp = ( DataPoint ) s.get( DataPoint.class, dp.getId() );
+		assertEquals( "original", dp.getDescription() );
+		s.delete( dp );
+		t.commit();
+		s.close();
+
+	}
+
 	public void testReadOnlyOnTextType() {
 		final String origText = "some huge text string";
 		final String newText = "some even bigger text string";



More information about the hibernate-commits mailing list