1
package org.hibernate.test.ops;
3
import junit.framework.Test;
5
import org.hibernate.Session;
6
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
11
* @author Steve Ebersole
13
public class DeleteTest extends AbstractOperationTestCase {
14
public DeleteTest(String name) {
18
public static Test suite() {
19
return new FunctionalTestClassTestSuite( DeleteTest.class );
22
public void testDeleteVersionedWithCollectionNoUpdate() {
23
// test adapted from HHH-1564...
24
Session s = openSession();
26
VersionedEntity c = new VersionedEntity( "c1", "child-1" );
27
VersionedEntity p = new VersionedEntity( "root", "root");
28
p.getChildren().add( c );
31
s.getTransaction().commit();
38
VersionedEntity loadedParent = ( VersionedEntity ) s.get( VersionedEntity.class, "root" );
39
s.delete( loadedParent );
40
s.getTransaction().commit();
43
assertInsertCount( 0 );
44
assertUpdateCount( 0 );
45
assertDeleteCount( 2 );
48
public void testNoUpdateOnDelete() {
49
Session s = openSession();
51
Node node = new Node( "test" );
53
s.getTransaction().commit();
61
s.getTransaction().commit();
64
assertUpdateCount( 0 );
65
assertInsertCount( 0 );
68
public void testNoUpdateOnDeleteWithCollection() {
69
Session s = openSession();
71
Node parent = new Node( "parent" );
72
Node child = new Node( "child" );
73
parent.getCascadingChildren().add( child );
75
s.getTransaction().commit();
82
parent = ( Node ) s.get( Node.class, "parent" );
84
s.getTransaction().commit();
87
assertUpdateCount( 0 );
88
assertInsertCount( 0 );
89
assertDeleteCount( 2 );