clearCounts(); Session s = openSession(); Transaction tx = s.beginTransaction(); Node root = new Node( "root" ); Node child = new Node( "child" ); root.addChild( child ); s.saveOrUpdate( root ); tx.commit(); s.close(); assertInsertCount( 2 ); clearCounts(); root.setDescription( "The root node" ); child.setDescription( "The child node" ); Node secondChild = new Node( "second child" ); root.addChild( secondChild ); s = openSession(); tx = s.beginTransaction(); s.saveOrUpdate( root ); tx.commit(); s.close(); assertInsertCount( 1 ); assertUpdateCount( 2 ); s = openSession(); tx = s.beginTransaction(); s.createQuery( "delete from Node where parent is not null" ).executeUpdate(); s.createQuery( "delete from Node" ).executeUpdate(); tx.commit(); s.close();
clearCounts(); Session s = openSession(); Transaction tx = s.beginTransaction(); NumberedNode root = new NumberedNode( "root" ); NumberedNode child = new NumberedNode( "child" ); root.addChild( child ); s.saveOrUpdate( root ); tx.commit(); s.close(); assertInsertCount( 2 ); clearCounts(); root.setDescription( "The root node" ); child.setDescription( "The child node" ); NumberedNode secondChild = new NumberedNode( "second child" ); root.addChild( secondChild ); s = openSession(); tx = s.beginTransaction(); s.saveOrUpdate( root ); tx.commit(); s.close(); assertInsertCount( 1 ); assertUpdateCount( 2 ); s = openSession(); tx = s.beginTransaction(); s.createQuery( "delete from NumberedNode where parent is not null" ).executeUpdate(); s.createQuery( "delete from NumberedNode" ).executeUpdate(); 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/SaveOrUpdateTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/SaveOrUpdateTest.java
Method name: void testSaveOrUpdateTree() Method name: void testSaveOrUpdateTreeWithGeneratedId()
Number of AST nodes: 28 Number of AST nodes: 28
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
		NumberedNode root = new NumberedNode( "root" );
5
		Node child = new Node( "child" );
5
		NumberedNode child = new NumberedNode( "child" );
6
		root.addChild( child );
6
		root.addChild( child );
7
		s.saveOrUpdate( root );
7
		s.saveOrUpdate( root );
8
		tx.commit();
8
		tx.commit();
9
		s.close();
9
		s.close();
10
		assertInsertCount( 2 );
10
		assertInsertCount( 2 );
11
		clearCounts();
11
		clearCounts();
12
		root.setDescription( "The root node" );
12
		root.setDescription( "The root node" );
13
		child.setDescription( "The child node" );
13
		child.setDescription( "The child node" );
14
		Node secondChild = new Node( "second child" );
14
		NumberedNode secondChild = new NumberedNode( "second child" );
15
		root.addChild( secondChild );
15
		root.addChild( secondChild );
16
		s = openSession();
16
		s = openSession();
17
		tx = s.beginTransaction();
17
		tx = s.beginTransaction();
18
		s.saveOrUpdate( root );
18
		s.saveOrUpdate( root );
19
		tx.commit();
19
		tx.commit();
20
		s.close();
20
		s.close();
21
		assertInsertCount( 1 );
21
		assertInsertCount( 1 );
22
		assertUpdateCount( 2 );
22
		assertUpdateCount( 2 );
23
		s = openSession();
23
		s = openSession();
24
		tx = s.beginTransaction();
24
		tx = s.beginTransaction();
25
		s.createQuery( "delete from Node where parent is not null" ).executeUpdate();
25
		s.createQuery( "delete from NumberedNode where parent is not null" ).executeUpdate();
26
		s.createQuery( "delete from Node" ).executeUpdate();
26
		s.createQuery( "delete from NumberedNode" ).executeUpdate();
27
		tx.commit();
27
		tx.commit();
28
		s.close();
28
		s.close();
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 declared in the same class
Number of node comparisons200
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements23
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment5
    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
    NumberedNode root = new NumberedNode("root");
    Preondition Violations
    Unmatched statement NumberedNode root=new NumberedNode("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    NumberedNode root = new NumberedNode("root");
    4
    Node root = new Node("root");
    4
    Node root = new Node("root");
    Preondition Violations
    Unmatched statement Node root=new Node("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                
                                                                                                    
    5
    NumberedNode child = new NumberedNode("child");
    Preondition Violations
    Unmatched statement NumberedNode child=new NumberedNode("child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    NumberedNode child = new NumberedNode("child");
    5
    Node child = new Node("child");
    5
    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
                                                                    
                                                    
    6
    root.addChild(child);
    Preondition Violations
    Unmatched statement root.addChild(child); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6
    root.addChild(child);
    6
    root.addChild(child);
    6
    root.addChild(child);
    Preondition Violations
    Unmatched statement root.addChild(child); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                    
    7
    s.saveOrUpdate(root);
    7
    s.saveOrUpdate(root);
    7
    s.saveOrUpdate(root);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.ops.Nodeorg.hibernate.test.ops.NumberedNodeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root
    • Make classes org.hibernate.test.ops.Node and org.hibernate.test.ops.NumberedNode extend a common superclass
    7
    s.saveOrUpdate(root);
    8
    tx.commit();
    8
    tx.commit();
    9
    s.close();
    9
    s.close();
    10
    assertInsertCount(2);
    10
    assertInsertCount(2);
    11
    clearCounts();
    11
    clearCounts();
    12
    root.setDescription("The root node");
    12
    root.setDescription("The root node");
    12
    root.setDescription("The root node");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.ops.Nodeorg.hibernate.test.ops.NumberedNodeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root
    • Make classes org.hibernate.test.ops.Node and org.hibernate.test.ops.NumberedNode extend a common superclass
    12
    root.setDescription("The root node");
    13
    child.setDescription("The child node");
    13
    child.setDescription("The child node");
    13
    child.setDescription("The child node");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.ops.Nodeorg.hibernate.test.ops.NumberedNodeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.ops.Node of variable child does not match with type org.hibernate.test.ops.NumberedNode of variable child
    • Make classes org.hibernate.test.ops.Node and org.hibernate.test.ops.NumberedNode extend a common superclass
    13
    child.setDescription("The child node");
                                                                                                                                
    14
    NumberedNode secondChild = new NumberedNode("second child");
    Preondition Violations
    Unmatched statement NumberedNode secondChild=new NumberedNode("second child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    14
    NumberedNode secondChild = new NumberedNode("second child");
    14
    Node secondChild = new Node("second child");
    14
    Node secondChild = new Node("second child");
    Preondition Violations
    Unmatched statement Node secondChild=new Node("second child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                
                                                                  
    15
    root.addChild(secondChild);
    Preondition Violations
    Unmatched statement root.addChild(secondChild); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    15
    root.addChild(secondChild);
    15
    root.addChild(secondChild);
    15
    root.addChild(secondChild);
    Preondition Violations
    Unmatched statement root.addChild(secondChild); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                  
    16
    s = openSession();
    16
    s = openSession();
    17
    tx = s.beginTransaction();
    17
    tx = s.beginTransaction();
    18
    s.saveOrUpdate(root);
    18
    s.saveOrUpdate(root);
    18
    s.saveOrUpdate(root);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.ops.Nodeorg.hibernate.test.ops.NumberedNodeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root
    • Make classes org.hibernate.test.ops.Node and org.hibernate.test.ops.NumberedNode extend a common superclass
    18
    s.saveOrUpdate(root);
    19
    tx.commit();
    19
    tx.commit();
    20
    s.close();
    20
    s.close();
    21
    assertInsertCount(1);
    21
    assertInsertCount(1);
    22
    assertUpdateCount(2);
    22
    assertUpdateCount(2);
    23
    s = openSession();
    23
    s = openSession();
    24
    tx = s.beginTransaction();
    24
    tx = s.beginTransaction();
    25
    s.createQuery("delete from Node where parent is not null").executeUpdate();
    25
    s.createQuery("delete from Node where parent is not null").executeUpdate();
    25
    s.createQuery("delete from NumberedNode where parent is not null").executeUpdate();
    Differences
    Expression1Expression2Difference
    "delete from Node where parent is not null""delete from NumberedNode where parent is not null"LITERAL_VALUE_MISMATCH
    25
    s.createQuery("delete from NumberedNode where parent is not null").executeUpdate();
    26
    s.createQuery("delete from Node").executeUpdate();
    26
    s.createQuery("delete from Node").executeUpdate();
    26
    s.createQuery("delete from NumberedNode").executeUpdate();
    Differences
    Expression1Expression2Difference
    "delete from Node""delete from NumberedNode"LITERAL_VALUE_MISMATCH
    26
    s.createQuery("delete from NumberedNode").executeUpdate();
    27
    tx.commit();
    27
    tx.commit();
    28
    s.close();
    28
    s.close();
    Precondition Violations (14)
    Row Violation
    1Unmatched statement NumberedNode root=new NumberedNode("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement Node root=new Node("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement NumberedNode child=new NumberedNode("child"); cannot be moved before the extracted code, because it has control dependencies 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 root.addChild(child); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement root.addChild(child); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root
    8Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root
    9Type org.hibernate.test.ops.Node of variable child does not match with type org.hibernate.test.ops.NumberedNode of variable child
    10Unmatched statement NumberedNode secondChild=new NumberedNode("second child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11Unmatched statement Node secondChild=new Node("second child"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Unmatched statement root.addChild(secondChild); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13Unmatched statement root.addChild(secondChild); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    14Type org.hibernate.test.ops.Node of variable root does not match with type org.hibernate.test.ops.NumberedNode of variable root