Session s = openSession(); Transaction t = s.beginTransaction(); assertNull( s.get( D.class, new Long(1) ) ); D d = new D(); d.setId( new Long(1) ); s.save(d); s.flush(); assertNotNull( s.get( D.class, new Long(1) ) ); s.delete(d); s.flush(); t.commit(); s.close();
Session session = openSession(); Transaction txn = session.beginTransaction(); Simple sim = new Simple(); sim.setDate( new Date() ); session.save( sim, new Long(1) ); Query q = session.createSQLQuery("select {sim.*} from Simple {sim} where {sim}.date_ = ?", "sim", Simple.class); q.setTimestamp( 0, sim.getDate() ); assertTrue ( q.list().size()==1 ); session.delete(sim); txn.commit(); session.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/ABCTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/SQLLoaderTest.java
Method name: void testGetSave() Method name: void testTS()
Number of AST nodes: 12 Number of AST nodes: 11
1
Session s = openSession();
1
Session session = openSession();
2
		Transaction t = s.beginTransaction();
2
		Transaction txn = session.beginTransaction();
3
		assertNull( s.get( D.class, new Long(1) ) );
3
		
4
		D d = new D();
5
		d.setId( new Long(1) );
6
		s.save(d);
7
		s.flush(
4
Simple sim = new Simple();
5
		sim.setDate( new Date() );
6
		session.save( sim, new Long(1) );
8
);
7
		Query q = session.createSQLQuery("select {sim.*} from Simple {sim} where {sim}.date_ = ?", "sim", Simple.class);
9
		assertNotNull( s.get( D.class, new Long(1) ) );
8
		q.setTimestamp( 0, sim.getDate() );
10
		s.delete(d);
9
		
11
		s.flush(
10
assertTrue ( q.list().size()==1 );
12
);
11
		session.delete(sim);
13
		t.commit();
12
		txn.commit();
14
		s.close();
13
		session.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 in different classes having the same super class
Number of node comparisons106
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
    1
    Session session = openSession();
    Differences
    Expression1Expression2Difference
    ssessionVARIABLE_NAME_MISMATCH
    1
    Session session = openSession();
    2
    Transaction t = s.beginTransaction();
    2
    Transaction t = s.beginTransaction();
    2
    Transaction txn = session.beginTransaction();
    Differences
    Expression1Expression2Difference
    ttxnVARIABLE_NAME_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    2
    Transaction txn = session.beginTransaction();
                                                          
    3
    Simple sim = new Simple();
    3
    assertNull(s.get(D.class, new Long(1)));
                                                                                        
                                                          
    4
    sim.setDate(new Date());
    4
    D d = new D();
                                  
    5
    d.setId(new Long(1));
                                                    
                                                                                                                                                                                                                                  
    6
    Query q = session.createSQLQuery("select {sim.*} from Simple {sim} where {sim}.date_ = ?", "sim", Simple.class);
    Preondition Violations
    Unmatched statement Query q=session.createSQLQuery("select {sim.*} from Simple {sim} where {sim}.date_ = ?","sim",Simple.class); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    Query q = session.createSQLQuery("select {sim.*} from Simple {sim} where {sim}.date_ = ?", "sim", Simple.class);
    6
    s.save(d);
                              
    7
    s.flush();
    7
    s.flush();
    5
    session.save(sim, new Long(1));
    Differences
    Expression1Expression2Difference
    flushsaveMETHOD_INVOCATION_NAME_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    s.flush()session.save(sim,new Long(1))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression session.save(sim,new Long(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression session.save(sim,new Long(1)) is a void method call, and thus it cannot be parameterized
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression session.save(sim,new Long(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression session.save(sim,new Long(1)) is a void method call, and thus it cannot be parameterized
    5
    session.save(sim, new Long(1));
                                                                          
    7
    q.setTimestamp(0, sim.getDate());
    8
    assertNotNull(s.get(D.class, new Long(1)));
                                                                                              
    9
    s.delete(d);
    9
    s.delete(d);
    9
    session.delete(sim);
    Differences
    Expression1Expression2Difference
    dsimVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Dorg.hibernate.test.legacy.SimpleVARIABLE_TYPE_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.D of variable d does not match with type org.hibernate.test.legacy.Simple of variable sim
    • Make classes org.hibernate.test.legacy.D and org.hibernate.test.legacy.Simple extend a common superclass
    9
    session.delete(sim);
    10
    s.flush();
    10
    s.flush();
    8
    assertTrue(q.list().size() == 1);
    Differences
    Expression1Expression2Difference
    flushassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    s.flush()assertTrue(q.list().size() == 1)ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(q.list().size() == 1) is a void method call, and thus it cannot be parameterized
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(q.list().size() == 1) is a void method call, and thus it cannot be parameterized
    8
    assertTrue(q.list().size() == 1);
    11
    t.commit();
    11
    t.commit();
    10
    txn.commit();
    Differences
    Expression1Expression2Difference
    ttxnVARIABLE_NAME_MISMATCH
    10
    txn.commit();
    12
    s.close();
    12
    s.close();
    11
    session.close();
    Differences
    Expression1Expression2Difference
    ssessionVARIABLE_NAME_MISMATCH
    11
    session.close();
    Precondition Violations (16)
    Row Violation
    1Unmatched statement Query q=session.createSQLQuery("select {sim.*} from Simple {sim} where {sim}.date_ = ?","sim",Simple.class); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression session.save(sim,new Long(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression s.flush() is a void method call, and thus it cannot be parameterized
    5Expression session.save(sim,new Long(1)) is a void method call, and thus it cannot be parameterized
    6Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression session.save(sim,new Long(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression s.flush() is a void method call, and thus it cannot be parameterized
    9Expression session.save(sim,new Long(1)) is a void method call, and thus it cannot be parameterized
    10Type org.hibernate.test.legacy.D of variable d does not match with type org.hibernate.test.legacy.Simple of variable sim
    11Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression s.flush() is a void method call, and thus it cannot be parameterized
    13Expression assertTrue(q.list().size() == 1) is a void method call, and thus it cannot be parameterized
    14Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression s.flush() is a void method call, and thus it cannot be parameterized
    16Expression assertTrue(q.list().size() == 1) is a void method call, and thus it cannot be parameterized