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 545c8853e9..cb3ca4d640 100755 --- a/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java +++ b/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyTest.java @@ -28,7 +28,7 @@ public class ReadOnlyTest extends FunctionalTestCase { } public String[] getMappings() { - return new String[] { "readonly/DataPoint.hbm.xml" }; + return new String[] { "readonly/DataPoint.hbm.xml", "readonly/TextHolder.hbm.xml" }; } public void configure(Configuration cfg) { @@ -117,5 +117,36 @@ public class ReadOnlyTest extends FunctionalTestCase { } + public void testReadOnlyOnTextType() { + final String origText = "some huge text string"; + final String newText = "some even bigger text string"; + + Session s = openSession(); + s.beginTransaction(); + s.setCacheMode( CacheMode.IGNORE ); + TextHolder holder = new TextHolder( origText ); + s.save( holder ); + Long id = holder.getId(); + s.getTransaction().commit(); + s.close(); + + s = openSession(); + s.beginTransaction(); + s.setCacheMode( CacheMode.IGNORE ); + holder = ( TextHolder ) s.get( TextHolder.class, id ); + s.setReadOnly( holder, true ); + holder.setTheText( newText ); + s.flush(); + s.getTransaction().commit(); + s.close(); + + s = openSession(); + s.beginTransaction(); + holder = ( TextHolder ) s.get( TextHolder.class, id ); + assertEquals( "change written to database", origText, holder.getTheText() ); + s.delete( holder ); + s.getTransaction().commit(); + s.close(); + } }