added additional test
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@12928 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
b1fdf81549
commit
81f31939c5
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue