clearCounts(); Session s = openSession(); Transaction tx = s.beginTransaction(); VersionedEntity root = new VersionedEntity( "root", "root" ); VersionedEntity child = new VersionedEntity( "c1", "child-1" ); root.getChildren().add( child ); child.setParent( root ); s.save(root); tx.commit(); s.close(); assertInsertCount( 2 ); assertUpdateCount( 0 ); assertDeleteCount( 0 ); s = openSession(); tx = s.beginTransaction(); s.delete( root ); tx.commit(); s.close(); assertUpdateCount( 0 ); assertDeleteCount( 2 );
Session s = openSession(); s.beginTransaction(); Node parent = new Node( "parent" ); Node child = new Node( "child" ); parent.getCascadingChildren().add( child ); s.persist( parent ); s.getTransaction().commit(); s.close(); clearCounts(); s = openSession(); s.beginTransaction(); parent = ( Node ) s.get( Node.class, "parent" ); s.delete( parent ); s.getTransaction().commit(); s.close(); assertUpdateCount( 0 ); assertInsertCount( 0 ); assertDeleteCount( 2 );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/CreateTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/DeleteTest.java
Method name: void testNoUpdatesOnCreateVersionedWithCollection() Method name: void testNoUpdateOnDeleteWithCollection()
Number of AST nodes: 20 Number of AST nodes: 18
1
clearCounts();
2
		Session s = openSession();
1
Session s = openSession();
3
		Transaction tx =
4
 s.beginTransaction();
2
        s.beginTransaction();
5
		VersionedEntity root = new VersionedEntity( "root", "root" );
3
		Node parent = new Node( "parent" );
6
		VersionedEntity child = new VersionedEntity( "c1", "child-1" );
4
		Node child = new Node( "child" );
7
		root.getChildren().add( child );
5
		parent.getCascadingChildren().add( child );
8
		child.setParent( root );
6
		s.persist( parent );
9
		s.save(root);
7
		s.
10
		tx.commit();
8
getTransaction().commit();
11
		s.close();
9
		s.close();
12
		assertInsertCount( 2 );
13
		assertUpdateCount( 0 );
14
		assertDeleteCount( 0 );
10
		clearCounts();
11

15
		s = openSession();
12
		s = openSession();
16
		tx = s.beginTransaction();
13
		s.beginTransaction();
14
		parent = ( Node ) s.get( Node.class, "parent" );
17
		s.delete( root );
15
		s.delete( parent );
18
		tx.commit();
16
		s.getTransaction().commit();
19
		s.close();
17
		s.close();
18

20
		assertUpdateCount( 0 );
19
		assertUpdateCount( 0 );
20
		assertInsertCount( 0 );
21
		assertDeleteCount( 2 );
21
		assertDeleteCount( 2 );
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are in different classes having the same super class
Number of node comparisons292
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment11
    Number of unmapped statements in the second code fragment9
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    clearCounts();
    9
    clearCounts();
    2
    Session s = openSession();
    1
    Session s = openSession();
                                                    
    2
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    s.beginTransaction();
                                                                        
    3
    Node parent = new Node("parent");
    Preondition Violations
    Unmatched statement Node parent=new Node("parent"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    Node parent = new Node("parent");
    3
    Transaction tx = s.beginTransaction();
    3
    Transaction tx = s.beginTransaction();
    Preondition Violations
    Unmatched statement Transaction tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                  
                                                                    
    4
    Node child = new Node("child");
    Preondition Violations
    Unmatched statement Node child=new Node("child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    Node child = new Node("child");
    4
    VersionedEntity root = new VersionedEntity("root", "root");
    4
    VersionedEntity root = new VersionedEntity("root", "root");
    Preondition Violations
    Unmatched statement VersionedEntity root=new VersionedEntity("root","root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                          
                                                                                            
    5
    parent.getCascadingChildren().add(child);
    5
    VersionedEntity child = new VersionedEntity("c1", "child-1");
    5
    VersionedEntity child = new VersionedEntity("c1", "child-1");
    Preondition Violations
    Unmatched statement VersionedEntity child=new VersionedEntity("c1","child-1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                              
                                              
    6
    s.persist(parent);
    Preondition Violations
    Unmatched statement s.persist(parent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    s.persist(parent);
    6
    root.getChildren().add(child);
                                                                      
                                                                  
    7
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    s.getTransaction().commit();
    7
    child.setParent(root);
    7
    child.setParent(root);
    Preondition Violations
    Unmatched statement child.setParent(root); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                      
    8
    s.save(root);
    8
    s.save(root);
    Preondition Violations
    Unmatched statement s.save(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
    9
    tx.commit();
    9
    tx.commit();
    Preondition Violations
    Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                  
    10
    s.close();
    8
    s.close();
                                                      
    11
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    s.beginTransaction();
                                                                                            
    12
    parent = (Node)s.get(Node.class, "parent");
    Preondition Violations
    Unmatched statement parent=(Node)s.get(Node.class,"parent"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    parent = (Node)s.get(Node.class, "parent");
    11
    assertInsertCount(2);
    11
    assertInsertCount(2);
    17
    assertInsertCount(0);
    Differences
    Expression1Expression2Difference
    20LITERAL_VALUE_MISMATCH
    17
    assertInsertCount(0);
    12
    assertUpdateCount(0);
                                                      
    13
    assertDeleteCount(0);
                                                      
    14
    s = openSession();
    10
    s = openSession();
    15
    tx = s.beginTransaction();
    15
    tx = s.beginTransaction();
    Preondition Violations
    Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    16
    s.delete(root);
    16
    s.delete(root);
    13
    s.delete(parent);
    Differences
    Expression1Expression2Difference
    rootparentVARIABLE_NAME_MISMATCH
    org.hibernate.test.ops.VersionedEntityorg.hibernate.test.ops.NodeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.ops.VersionedEntity of variable root does not match with type org.hibernate.test.ops.Node of variable parent
    • Make classes org.hibernate.test.ops.VersionedEntity and org.hibernate.test.ops.Node extend a common superclass
    13
    s.delete(parent);
                                                                    
    14
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    s.getTransaction().commit();
    17
    tx.commit();
    17
    tx.commit();
    Preondition Violations
    Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                    
    18
    s.close();
    15
    s.close();
    19
    assertUpdateCount(0);
    16
    assertUpdateCount(0);
    20
    assertDeleteCount(2);
    18
    assertDeleteCount(2);
    Precondition Violations (17)
    Row Violation
    1Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Node parent=new Node("parent"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement Transaction tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement Node child=new Node("child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement VersionedEntity root=new VersionedEntity("root","root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement VersionedEntity child=new VersionedEntity("c1","child-1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement s.persist(parent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement child.setParent(root); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement s.save(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement parent=(Node)s.get(Node.class,"parent"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Type org.hibernate.test.ops.VersionedEntity of variable root does not match with type org.hibernate.test.ops.Node of variable parent
    16Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement tx.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted