clearCounts(); Session s = openSession(); Transaction tx = s.beginTransaction(); Node root = new Node("root"); Node child = new Node("child"); Node grandchild = new Node("grandchild"); root.addChild(child); child.addChild(grandchild); s.merge(root); tx.commit(); s.close(); assertInsertCount(3); assertUpdateCount(0); clearCounts(); grandchild.setDescription("the grand child"); Node grandchild2 = new Node("grandchild2"); child.addChild( grandchild2 ); s = openSession(); tx = s.beginTransaction(); s.merge(root); tx.commit(); s.close(); assertInsertCount(1); assertUpdateCount(1); clearCounts(); Node child2 = new Node("child2"); Node grandchild3 = new Node("grandchild3"); child2.addChild( grandchild3 ); root.addChild(child2); s = openSession(); tx = s.beginTransaction(); s.merge(root); tx.commit(); s.close(); assertInsertCount(2); assertUpdateCount(0); clearCounts(); s = openSession(); tx = s.beginTransaction(); s.delete(grandchild); s.delete(grandchild2); s.delete(grandchild3); s.delete(child); s.delete(child2); s.delete(root); tx.commit(); s.close();
clearCounts(); Session s = openSession(); Transaction tx = s.beginTransaction(); Node root = new Node( "root" ); Node child = new Node( "child" ); Node grandchild = new Node( "grandchild" ); root.addChild( child ); child.addChild( grandchild ); s.saveOrUpdate( root ); tx.commit(); s.close(); assertInsertCount( 3 ); assertUpdateCount( 0 ); clearCounts(); grandchild.setDescription( "the grand child" ); Node grandchild2 = new Node( "grandchild2" ); child.addChild( grandchild2 ); s = openSession(); tx = s.beginTransaction(); s.saveOrUpdate( root ); tx.commit(); s.close(); assertInsertCount( 1 ); assertUpdateCount( 1 ); clearCounts(); Node child2 = new Node( "child2" ); Node grandchild3 = new Node( "grandchild3" ); child2.addChild( grandchild3 ); root.addChild( child2 ); s = openSession(); tx = s.beginTransaction(); s.saveOrUpdate( root ); tx.commit(); s.close(); assertInsertCount( 2 ); assertUpdateCount( 0 ); clearCounts(); s = openSession(); tx = s.beginTransaction(); s.delete( grandchild ); s.delete( grandchild2 ); s.delete( grandchild3 ); s.delete( child ); s.delete( child2 ); s.delete( root ); tx.commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/SaveOrUpdateTest.java
Method name: void testMergeDeepTree() Method name: void testSaveOrUpdateDeepTree()
Number of AST nodes: 47 Number of AST nodes: 47
1
clearCounts();
1
clearCounts();
2
		Session s = openSession();
2
		Session s = openSession();
3
		Transaction tx = s.beginTransaction();
3
		Transaction tx = s.beginTransaction();
4
		Node root = new Node("root");
4
		Node root = new Node( "root" );
5
		Node child = new Node("child");
5
		Node child = new Node( "child" );
6
		Node grandchild = new Node("grandchild");
6
		Node grandchild = new Node( "grandchild" );
7
		root.addChild(child);
7
		root.addChild( child );
8
		child.addChild(grandchild);
8
		child.addChild( grandchild );
9
		s.merge(root);
9
		s.saveOrUpdate( root );
10
		tx.commit();
10
		tx.commit();
11
		s.close();
11
		s.close();
12
		assertInsertCount(3);
12
		assertInsertCount( 3 );
13
		assertUpdateCount(0);
13
		assertUpdateCount( 0 );
14
		clearCounts();
14
		clearCounts();
15
		grandchild.setDescription("the grand child");
15
		grandchild.setDescription( "the grand child" );
16
		Node grandchild2 = new Node("grandchild2");
16
		Node grandchild2 = new Node( "grandchild2" );
17
		child.addChild( grandchild2 );
17
		child.addChild( grandchild2 );
18
		s = openSession();
18
		s = openSession();
19
		tx = s.beginTransaction();
19
		tx = s.beginTransaction();
20
		s.merge(root);
20
		s.saveOrUpdate( root );
21
		tx.commit();
21
		tx.commit();
22
		s.close();
22
		s.close();
23
		assertInsertCount(1);
23
		assertInsertCount( 1 );
24
		assertUpdateCount(1);
24
		assertUpdateCount( 1 );
25
		clearCounts();
25
		clearCounts();
26
		Node child2 = new Node("child2");
26
		Node child2 = new Node( "child2" );
27
		Node grandchild3 = new Node("grandchild3");
27
		Node grandchild3 = new Node( "grandchild3" );
28
		child2.addChild( grandchild3 );
28
		child2.addChild( grandchild3 );
29
		root.addChild(child2);
29
		root.addChild( child2 );
30
		s = openSession();
30
		s = openSession();
31
		tx = s.beginTransaction();
31
		tx = s.beginTransaction();
32
		s.merge(root);
32
		s.saveOrUpdate( root );
33
		tx.commit();
33
		tx.commit();
34
		s.close();
34
		s.close();
35
		assertInsertCount(2);
35
		assertInsertCount( 2 );
36
		assertUpdateCount(0);
36
		assertUpdateCount( 0 );
37
		clearCounts();
37
		clearCounts();
38
		s = openSession();
38
		s = openSession();
39
		tx = s.beginTransaction();
39
		tx = s.beginTransaction();
40
		s.delete(grandchild);
40
		s.delete( grandchild );
41
		s.delete(grandchild2);
41
		s.delete( grandchild2 );
42
		s.delete(grandchild3);
42
		s.delete( grandchild3 );
43
		s.delete(child);
43
		s.delete( child );
44
		s.delete(child2);
44
		s.delete( child2 );
45
		s.delete(root);
45
		s.delete( root );
46
		tx.commit();
46
		tx.commit();
47
		s.close();
47
		s.close();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
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 comparisons402
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements44
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    clearCounts();
    1
    clearCounts();
    2
    Session s = openSession();
    2
    Session s = openSession();
    3
    Transaction tx = s.beginTransaction();
    3
    Transaction tx = s.beginTransaction();
    4
    Node root = new Node("root");
    4
    Node root = new Node("root");
    5
    Node child = new Node("child");
    5
    Node child = new Node("child");
    6
    Node grandchild = new Node("grandchild");
    6
    Node grandchild = new Node("grandchild");
    7
    root.addChild(child);
    7
    root.addChild(child);
    8
    child.addChild(grandchild);
    8
    child.addChild(grandchild);
                                                    
    9
    s.saveOrUpdate(root);
    Preondition Violations
    Unmatched statement s.saveOrUpdate(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    s.saveOrUpdate(root);
    9
    s.merge(root);
    9
    s.merge(root);
    Preondition Violations
    Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                      
    10
    tx.commit();
    10
    tx.commit();
    11
    s.close();
    11
    s.close();
    12
    assertInsertCount(3);
    12
    assertInsertCount(3);
    13
    assertUpdateCount(0);
    13
    assertUpdateCount(0);
    14
    clearCounts();
    14
    clearCounts();
    15
    grandchild.setDescription("the grand child");
    15
    grandchild.setDescription("the grand child");
    16
    Node grandchild2 = new Node("grandchild2");
    16
    Node grandchild2 = new Node("grandchild2");
    17
    child.addChild(grandchild2);
    17
    child.addChild(grandchild2);
    18
    s = openSession();
    18
    s = openSession();
    19
    tx = s.beginTransaction();
    19
    tx = s.beginTransaction();
                                                      
    20
    s.saveOrUpdate(root);
    Preondition Violations
    Unmatched statement s.saveOrUpdate(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20
    s.saveOrUpdate(root);
    20
    s.merge(root);
    20
    s.merge(root);
    Preondition Violations
    Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                        
    21
    tx.commit();
    21
    tx.commit();
    22
    s.close();
    22
    s.close();
    23
    assertInsertCount(1);
    23
    assertInsertCount(1);
    24
    assertUpdateCount(1);
    24
    assertUpdateCount(1);
    25
    clearCounts();
    25
    clearCounts();
    26
    Node child2 = new Node("child2");
    26
    Node child2 = new Node("child2");
    27
    Node grandchild3 = new Node("grandchild3");
    27
    Node grandchild3 = new Node("grandchild3");
    28
    child2.addChild(grandchild3);
    28
    child2.addChild(grandchild3);
    29
    root.addChild(child2);
    29
    root.addChild(child2);
    30
    s = openSession();
    30
    s = openSession();
    31
    tx = s.beginTransaction();
    31
    tx = s.beginTransaction();
                                                      
    32
    s.saveOrUpdate(root);
    Preondition Violations
    Unmatched statement s.saveOrUpdate(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    32
    s.saveOrUpdate(root);
    32
    s.merge(root);
    32
    s.merge(root);
    Preondition Violations
    Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                        
    33
    tx.commit();
    33
    tx.commit();
    34
    s.close();
    34
    s.close();
    35
    assertInsertCount(2);
    35
    assertInsertCount(2);
    36
    assertUpdateCount(0);
    36
    assertUpdateCount(0);
    37
    clearCounts();
    37
    clearCounts();
    38
    s = openSession();
    38
    s = openSession();
    39
    tx = s.beginTransaction();
    39
    tx = s.beginTransaction();
    40
    s.delete(grandchild);
    40
    s.delete(grandchild);
    41
    s.delete(grandchild2);
    41
    s.delete(grandchild2);
    42
    s.delete(grandchild3);
    42
    s.delete(grandchild3);
    43
    s.delete(child);
    43
    s.delete(child);
    44
    s.delete(child2);
    44
    s.delete(child2);
    45
    s.delete(root);
    45
    s.delete(root);
    46
    tx.commit();
    46
    tx.commit();
    47
    s.close();
    47
    s.close();
    Precondition Violations (6)
    Row Violation
    1Unmatched statement s.saveOrUpdate(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement s.saveOrUpdate(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement s.saveOrUpdate(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement s.merge(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted