Session s = openSession(); Baz baz = new Baz(); baz.setDefaults(); s.save(baz); s.flush(); s.connection().commit(); s.close(); s = openSession(); s.load( Baz.class, baz.getCode() ); s.flush(); s.connection().commit(); s.close(); s = openSession(); baz = (Baz) s.load( Baz.class, baz.getCode() ); s.delete(baz); s.flush(); s.connection().commit(); s.close();
Session s = openSession(); s.getTransaction().begin(); Employer jboss = new Employer(); s.persist( jboss ); s.getTransaction().commit(); s.clear(); s.getTransaction().begin(); Employer otherJboss; otherJboss = (Employer) s.get( Employer.class, jboss.getId() ); s.delete( otherJboss ); s.getTransaction().commit(); s.clear(); jboss.setVers( new Integer(1) ); s.getTransaction().begin(); s.merge( jboss ); s.getTransaction().commit(); s.close(); cleanup();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java
Method name: void testCollectionCache() Method name: void testDeleteAndMerge()
Number of AST nodes: 18 Number of AST nodes: 18
1
Session s = openSession();
1
Session s = openSession();
2
		Baz baz = new Baz();
2
		
3
		baz.setDefaults();
4
		s.save(baz);
5
		s.flush();
6
		s.conne
3
s.getTransaction().begin();
4
		Employer jboss = new Employer();
5
		s.persist( jboss );
7
ction().commit();
6
		s.getTransaction().commit();
8
		s.close();
7
		s.clear();
9
		s = openSession();
8
		s
10
		s.load( Baz
9
.getTransaction().begin();
10
		Employer otherJboss;
11
.class, baz.getCode() );
11
		otherJboss = (Employer) s.get( Employer.class, 
12
		s.flush();
13
		s.conne
12
jboss.getId() );
13
		s.delete( otherJboss );
14
ction().commit();
14
		s.getTransaction().commit();
15
		s.close();
15
		s.clear();
16
		s = openSession();
16
		
17
		baz = (Baz) s.load( Baz.class, baz.getCode() );
18
		s.delete(baz);
19
		s.flush();
20
		s.conne
17
jboss.setVers( new Integer(1) );
18
		s.getTransaction().begin();
19
		s.merge( jboss );
21
ction().commit();
20
		s.getTransaction().commit();
22
		s.close();
21
		s.close();
22
		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 comparisons324
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment13
    Number of unmapped statements in the second code fragment13
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
    1
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.classic.Sessionorg.hibernate.SessionSUBCLASS_TYPE_MISMATCH
    org.hibernate.classic.Sessionorg.hibernate.SessionSUBCLASS_TYPE_MISMATCH
    1
    Session s = openSession();
                                                                
    2
    s.getTransaction().begin();
    Preondition Violations
    Unmatched statement s.getTransaction().begin(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    s.getTransaction().begin();
    2
    Baz baz = new Baz();
                                              
                                                                      
    3
    Employer jboss = new Employer();
    3
    baz.setDefaults();
    3
    baz.setDefaults();
    Preondition Violations
    Unmatched statement baz.setDefaults(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                              
                                            
    4
    s.persist(jboss);
    Preondition Violations
    Unmatched statement s.persist(jboss); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    s.persist(jboss);
    4
    s.save(baz);
    4
    s.save(baz);
    Preondition Violations
    Unmatched statement s.save(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                  
    5
    s.flush();
    5
    s.flush();
    6
    s.clear();
    Differences
    Expression1Expression2Difference
    flushclearMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.classic.Sessionorg.hibernate.SessionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.clear() 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 s.clear() is a void method call, and thus it cannot be parameterized
    6
    s.clear();
    6
    s.connection().commit();
    6
    s.connection().commit();
    5
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    connectiongetTransactionMETHOD_INVOCATION_NAME_MISMATCH
    java.sql.Connectionorg.hibernate.TransactionVARIABLE_TYPE_MISMATCH
    org.hibernate.classic.Sessionorg.hibernate.SessionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression s.connection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.sql.Connection of variable s.connection() does not match with type org.hibernate.Transaction of variable s.getTransaction()
    • Make classes java.sql.Connection and org.hibernate.Transaction extend a common superclass
    5
    s.getTransaction().commit();
                                                                
    7
    s.getTransaction().begin();
    Preondition Violations
    Unmatched statement s.getTransaction().begin(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    s.getTransaction().begin();
                                                  
    8
    Employer otherJboss;
                                                                                                                            
    9
    otherJboss = (Employer)s.get(Employer.class, jboss.getId());
    Preondition Violations
    Unmatched statement otherJboss=(Employer)s.get(Employer.class,jboss.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    otherJboss = (Employer)s.get(Employer.class, jboss.getId());
    7
    s.close();
    7
    s.close();
    17
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.classic.Sessionorg.hibernate.SessionSUBCLASS_TYPE_MISMATCH
    17
    s.close();
    8
    s = openSession();
    8
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                          
    9
    s.load(Baz.class, baz.getCode());
                                                                          
                                                      
    10
    s.delete(otherJboss);
    Preondition Violations
    Unmatched statement s.delete(otherJboss); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    s.delete(otherJboss);
                                                                    
    11
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    s.getTransaction().commit();
    10
    s.flush();
    10
    s.flush();
    18
    cleanup();
    Differences
    Expression1Expression2Difference
    flushcleanupMETHOD_INVOCATION_NAME_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 cleanup() 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 cleanup() is a void method call, and thus it cannot be parameterized
    18
    cleanup();
    11
    s.connection().commit();
                                                            
                                
    12
    s.clear();
    Preondition Violations
    Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    s.clear();
    12
    s.close();
                                
                                                                        
    13
    jboss.setVers(new Integer(1));
    Preondition Violations
    Unmatched statement jboss.setVers(new Integer(1)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13
    jboss.setVers(new Integer(1));
    13
    s = openSession();
    13
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                            
                                                                  
    14
    s.getTransaction().begin();
    Preondition Violations
    Unmatched statement s.getTransaction().begin(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    s.getTransaction().begin();
    14
    baz = (Baz)s.load(Baz.class, baz.getCode());
                                                                                              
                                          
    15
    s.merge(jboss);
    Preondition Violations
    Unmatched statement s.merge(jboss); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    s.merge(jboss);
    15
    s.delete(baz);
                                        
                                                                    
    16
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    s.getTransaction().commit();
    16
    s.flush();
                                
    17
    s.connection().commit();
                                                            
    18
    s.close();
                                
    Precondition Violations (29)
    Row Violation
    1Unmatched statement s.getTransaction().begin(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement baz.setDefaults(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement s.persist(jboss); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement s.save(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression s.flush() is a void method call, and thus it cannot be parameterized
    8Expression s.clear() is a void method call, and thus it cannot be parameterized
    9Expression s.connection() cannot be parameterized, 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
    11Type java.sql.Connection of variable s.connection() does not match with type org.hibernate.Transaction of variable s.getTransaction()
    12Unmatched statement s.getTransaction().begin(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement otherJboss=(Employer)s.get(Employer.class,jboss.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement s.delete(otherJboss); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression s.flush() is a void method call, and thus it cannot be parameterized
    19Expression cleanup() is a void method call, and thus it cannot be parameterized
    20Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression s.flush() is a void method call, and thus it cannot be parameterized
    22Expression cleanup() is a void method call, and thus it cannot be parameterized
    23Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24Unmatched statement jboss.setVers(new Integer(1)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    25Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    26Unmatched statement s.getTransaction().begin(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    27Unmatched statement s.merge(jboss); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    28Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29Clone fragment #1 returns variable s with type org.hibernate.classic.Session , while Clone fragment #2 returns variable s with type org.hibernate.Session