TestData testData = new TestData(); testData.create(); Session session = openSession(); Transaction txn = session.beginTransaction(); Stock stock = ( Stock ) session.get( Stock.class, new Long( 1 ) ); assertEquals( "Something wrong!", new Long( 1 ), stock.getId() ); txn.commit(); session.close(); testData.destroy();
TestData data = new TestData(); data.prepare(); Session s = openSession(); Transaction t = s.beginTransaction(); int count = s.createQuery( "delete Animal where mother = :mother" ) .setEntity( "mother", data.butterfly ) .executeUpdate(); assertEquals( 1, count ); 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/entitymode/multi/MultiRepresentationTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java
Method name: void testPojoRetreival() Method name: void testDeleteRestrictedOnManyToOne()
Number of AST nodes: 9 Number of AST nodes: 9
1
TestData testData = new TestData();
1
TestData data = new TestData();
2
		testData.create();
2
		data.prepare();
3
		Session session = openSession();
3
		Session s = openSession();
4
		Transaction txn = session.beginTransaction();
4
		Transaction t = s.beginTransaction();
5
		Stock stock = ( Stock ) session.get( Stock.class, new Long( 1 ) );
5
		
6
		assertEquals( "Something wrong!", new Long( 1 ), stock.getId()
6
int count = s.createQuery( "delete Animal where mother = :mother" )
7
				.setEntity( "mother", data.butterfly )
8
				.executeUpdate();
7
 );
9
		assertEquals( 1, count );
8
		txn.commit();
10
		t.commit();
9
		session.close();
11
		s.close();
10
		testData.destroy();
12
		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 in different classes having the same super class
Number of node comparisons61
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    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
    TestData data = new TestData();
    1
    TestData testData = new TestData();
                                                                            
                                        
    2
    data.prepare();
    2
    testData.create();
    2
    testData.create();
    6
    assertEquals(1, count);
    Differences
    Expression1Expression2Difference
    createassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    testData.create()assertEquals(1,count)ARGUMENT_NUMBER_MISMATCH
    testDataMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression testData.create() is a void method call, and thus it cannot be parameterized
    Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized
    Expression testData.create() is a void method call, and thus it cannot be parameterized
    Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized
    6
    assertEquals(1, count);
    3
    Session session = openSession();
    3
    Session session = openSession();
    3
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    3
    Session s = openSession();
    4
    Transaction txn = session.beginTransaction();
    4
    Transaction txn = session.beginTransaction();
    4
    Transaction t = s.beginTransaction();
    Differences
    Expression1Expression2Difference
    txntVARIABLE_NAME_MISMATCH
    sessionsVARIABLE_NAME_MISMATCH
    4
    Transaction t = s.beginTransaction();
                                                                                                                                                                                                                                                
    5
    int count = s.createQuery("delete Animal where mother = :mother").setEntity("mother", data.butterfly).executeUpdate();
    Preondition Violations
    Unmatched statement int count=s.createQuery("delete Animal where mother = :mother").setEntity("mother",data.butterfly).executeUpdate(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    int count = s.createQuery("delete Animal where mother = :mother").setEntity("mother", data.butterfly).executeUpdate();
    5
    Stock stock = (Stock)session.get(Stock.class, new Long(1));
    5
    Stock stock = (Stock)session.get(Stock.class, new Long(1));
    Preondition Violations
    Unmatched statement Stock stock=(Stock)session.get(Stock.class,new Long(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                          
    6
    assertEquals("Something wrong!", new Long(1), stock.getId());
    6
    assertEquals("Something wrong!", new Long(1), stock.getId());
    9
    data.cleanup();
    Differences
    Expression1Expression2Difference
    assertEqualscleanupMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals("Something wrong!",new Long(1),stock.getId())data.cleanup()ARGUMENT_NUMBER_MISMATCH
    dataMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertEquals("Something wrong!",new Long(1),stock.getId()) is a void method call, and thus it cannot be parameterized
    Expression data.cleanup() is a void method call, and thus it cannot be parameterized
    Expression assertEquals("Something wrong!",new Long(1),stock.getId()) is a void method call, and thus it cannot be parameterized
    Expression data.cleanup() is a void method call, and thus it cannot be parameterized
    9
    data.cleanup();
    7
    txn.commit();
    7
    txn.commit();
    7
    t.commit();
    Differences
    Expression1Expression2Difference
    txntVARIABLE_NAME_MISMATCH
    7
    t.commit();
    8
    session.close();
    8
    session.close();
    8
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    8
    s.close();
    9
    testData.destroy();
                                                
    Precondition Violations (10)
    Row Violation
    1Expression testData.create() is a void method call, and thus it cannot be parameterized
    2Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized
    3Expression testData.create() is a void method call, and thus it cannot be parameterized
    4Expression assertEquals(1,count) is a void method call, and thus it cannot be parameterized
    5Unmatched statement int count=s.createQuery("delete Animal where mother = :mother").setEntity("mother",data.butterfly).executeUpdate(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement Stock stock=(Stock)session.get(Stock.class,new Long(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression assertEquals("Something wrong!",new Long(1),stock.getId()) is a void method call, and thus it cannot be parameterized
    8Expression data.cleanup() is a void method call, and thus it cannot be parameterized
    9Expression assertEquals("Something wrong!",new Long(1),stock.getId()) is a void method call, and thus it cannot be parameterized
    10Expression data.cleanup() is a void method call, and thus it cannot be parameterized