diff --git a/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java b/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java index b708ff2bf1..eaa7b4fb73 100755 --- a/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java +++ b/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java @@ -141,6 +141,43 @@ public class ReadOnlyTest extends FunctionalTestCase { } + 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";