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 statements12
    Number of unmapped statements in the first code fragment8
    Number of unmapped statements in the second code fragment6
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    clearCounts();
    1
    clearCounts();
    6
    s.persist(parent);
    Differences
    Expression1Expression2Difference
    clearCountspersistMETHOD_INVOCATION_NAME_MISMATCH
    clearCounts()s.persist(parent)ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.persist(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    Expression s.persist(parent) is a void method call, and thus it cannot be parameterized
    Expression s.persist(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    Expression s.persist(parent) is a void method call, and thus it cannot be parameterized
    6
    s.persist(parent);
    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");
    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");
    4
    VersionedEntity root = new VersionedEntity("root", "root");
                                                                                                                          
                                                                                            
    5
    parent.getCascadingChildren().add(child);
    5
    VersionedEntity child = new VersionedEntity("c1", "child-1");
                                                                                                                              
    6
    root.getChildren().add(child);
                                                                      
    7
    child.setParent(root);
                                                      
    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();
    7
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    txs.getTransaction()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    s.getTransaction().commit();
    10
    s.close();
    8
    s.close();
    11
    assertInsertCount(2);
    11
    assertInsertCount(2);
    9
    clearCounts();
    Differences
    Expression1Expression2Difference
    assertInsertCountclearCountsMETHOD_INVOCATION_NAME_MISMATCH
    assertInsertCount(2)clearCounts()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    9
    clearCounts();
                                                      
    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");
    12
    assertUpdateCount(0);
    16
    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);
    17
    tx.commit();
    17
    tx.commit();
    14
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    txs.getTransaction()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    s.getTransaction().commit();
    18
    s.close();
    15
    s.close();
    19
    assertUpdateCount(0);
    19
    assertUpdateCount(0);
    17
    assertInsertCount(0);
    Differences
    Expression1Expression2Difference
    assertUpdateCountassertInsertCountMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized
    Expression assertInsertCount(0) is a void method call, and thus it cannot be parameterized
    17
    assertInsertCount(0);
    20
    assertDeleteCount(2);
    18
    assertDeleteCount(2);
    Precondition Violations (20)
    Row Violation
    1Expression s.persist(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression clearCounts() is a void method call, and thus it cannot be parameterized
    3Expression s.persist(parent) is a void method call, and thus it cannot be parameterized
    4Expression s.persist(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression clearCounts() is a void method call, and thus it cannot be parameterized
    6Expression s.persist(parent) is a void method call, and thus it cannot be parameterized
    7Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched 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
    9Unmatched statement s.save(root); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    12Expression clearCounts() is a void method call, and thus it cannot be parameterized
    13Expression assertInsertCount(2) is a void method call, and thus it cannot be parameterized
    14Expression clearCounts() is a void method call, and thus it cannot be parameterized
    15Unmatched 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
    16Unmatched statement tx=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Type org.hibernate.test.ops.VersionedEntity of variable root does not match with type org.hibernate.test.ops.Node of variable parent
    18Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression assertUpdateCount(0) is a void method call, and thus it cannot be parameterized
    20Expression assertInsertCount(0) is a void method call, and thus it cannot be parameterized