HHH-4642 : added test cases showing unexpected results when an updated entity is changed from read-only to modifiable
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18271 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
3748f29945
commit
d66cfe664a
|
@ -127,7 +127,7 @@ public class ReadOnlyVersionedNodesTest extends FunctionalTestCase {
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetUpdateReadOnlyTwice() throws Exception {
|
public void testUpdateSetReadOnlyTwice() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
VersionedNode node = new VersionedNode( "node", "node" );
|
VersionedNode node = new VersionedNode( "node", "node" );
|
||||||
|
@ -192,6 +192,72 @@ public class ReadOnlyVersionedNodesTest extends FunctionalTestCase {
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testUpdateSetReadOnlySetModifiableFailureExpected() throws Exception {
|
||||||
|
Session s = openSession();
|
||||||
|
s.beginTransaction();
|
||||||
|
VersionedNode node = new VersionedNode( "node", "node" );
|
||||||
|
s.persist( node );
|
||||||
|
s.getTransaction().commit();
|
||||||
|
s.close();
|
||||||
|
|
||||||
|
clearCounts();
|
||||||
|
|
||||||
|
s = openSession();
|
||||||
|
|
||||||
|
s.beginTransaction();
|
||||||
|
node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
|
||||||
|
node.setName( "node-name" );
|
||||||
|
s.setReadOnly( node, true );
|
||||||
|
s.setReadOnly( node, false );
|
||||||
|
s.getTransaction().commit();
|
||||||
|
s.close();
|
||||||
|
|
||||||
|
assertUpdateCount( 1 );
|
||||||
|
assertInsertCount( 0 );
|
||||||
|
|
||||||
|
s = openSession();
|
||||||
|
s.beginTransaction();
|
||||||
|
node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
|
||||||
|
assertEquals( "node-name", node.getName() );
|
||||||
|
assertEquals( 1, node.getVersion() );
|
||||||
|
s.delete( node );
|
||||||
|
s.getTransaction().commit();
|
||||||
|
s.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSetReadOnlyUpdateSetModifiableFailureExpected() throws Exception {
|
||||||
|
Session s = openSession();
|
||||||
|
s.beginTransaction();
|
||||||
|
VersionedNode node = new VersionedNode( "node", "node" );
|
||||||
|
s.persist( node );
|
||||||
|
s.getTransaction().commit();
|
||||||
|
s.close();
|
||||||
|
|
||||||
|
clearCounts();
|
||||||
|
|
||||||
|
s = openSession();
|
||||||
|
|
||||||
|
s.beginTransaction();
|
||||||
|
node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
|
||||||
|
s.setReadOnly( node, true );
|
||||||
|
node.setName( "node-name" );
|
||||||
|
s.setReadOnly( node, false );
|
||||||
|
s.getTransaction().commit();
|
||||||
|
s.close();
|
||||||
|
|
||||||
|
assertUpdateCount( 1 );
|
||||||
|
assertInsertCount( 0 );
|
||||||
|
|
||||||
|
s = openSession();
|
||||||
|
s.beginTransaction();
|
||||||
|
node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
|
||||||
|
assertEquals( "node-name", node.getName() );
|
||||||
|
assertEquals( 1, node.getVersion() );
|
||||||
|
s.delete( node );
|
||||||
|
s.getTransaction().commit();
|
||||||
|
s.close();
|
||||||
|
}
|
||||||
|
|
||||||
public void testAddNewChildToReadOnlyParent() throws Exception {
|
public void testAddNewChildToReadOnlyParent() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
|
|
Loading…
Reference in New Issue