TestData data = new TestData(); data.prepare(); Session s = openSession(); Transaction t = s.beginTransaction(); s.createQuery( "insert into Pickup (id, vin, owner) select id, vin, owner from Car" ).executeUpdate(); t.commit(); t = s.beginTransaction(); s.createQuery( "delete Vehicle" ).executeUpdate(); t.commit(); s.close(); data.cleanup();
TestData data = new TestData(); data.prepare(); Session s = openSession(); Transaction t = s.beginTransaction(); s.createQuery( "insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human" ).executeUpdate(); t.commit(); t = s.beginTransaction(); t.commit(); s.close(); data.cleanup();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java
Method name: void testSimpleInsert() Method name: void testInsertWithManyToOne()
Number of AST nodes: 11 Number of AST nodes: 10
1
TestData data = new TestData();
1
TestData data = new TestData();
2
		data.prepare();
2
		data.prepare();
3
		Session s = openSession();
3
		Session s = openSession();
4
		Transaction t = s.beginTransaction();
4
		Transaction t = s.beginTransaction();
5
		s.createQuery( "insert into Pickup (id, vin, owner) select id, vin, owner from Car" ).executeUpdate();
5
		s.createQuery( "insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human" ).executeUpdate();
6
		
7
		t.commit();
6
		t.commit();
8
		t = s.beginTransaction();
7
		t = s.beginTransaction();
9
		s.createQuery( "delete Vehicle" ).executeUpdate();
10
		
11
		t.commit();
8
		t.commit();
12
		s.close();
9
		s.close();
13
		data.cleanup();
10
		data.cleanup();
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 comparisons49
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    TestData data = new TestData();
    1
    TestData data = new TestData();
    2
    data.prepare();
    2
    data.prepare();
    3
    Session s = openSession();
    3
    Session s = openSession();
    4
    Transaction t = s.beginTransaction();
    4
    Transaction t = s.beginTransaction();
    5
    s.createQuery("insert into Pickup (id, vin, owner) select id, vin, owner from Car").executeUpdate();
    5
    s.createQuery("insert into Pickup (id, vin, owner) select id, vin, owner from Car").executeUpdate();
    5
    s.createQuery("insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human").executeUpdate();
    Differences
    Expression1Expression2Difference
    "insert into Pickup (id, vin, owner) select id, vin, owner from Car""insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human"LITERAL_VALUE_MISMATCH
    5
    s.createQuery("insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human").executeUpdate();
    6
    t.commit();
    6
    t.commit();
    7
    t = s.beginTransaction();
    7
    t = s.beginTransaction();
    8
    s.createQuery("delete Vehicle").executeUpdate();
                                                                                                          
    9
    t.commit();
    8
    t.commit();
    10
    s.close();
    9
    s.close();
    11
    data.cleanup();
    10
    data.cleanup();
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables s , while Clone fragment #2 returns variables