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 statements8
    Number of unmapped statements in the first code fragment10
    Number of unmapped statements in the second code fragment10
    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();
                                                          
                                                                
    2
    s.getTransaction().begin();
    2
    Baz baz = new Baz();
                                              
                                                                      
    3
    Employer jboss = new Employer();
                                            
    4
    s.persist(jboss);
                                                                
    7
    s.getTransaction().begin();
                                                  
    8
    Employer otherJboss;
                                                                                                                            
    9
    otherJboss = (Employer)s.get(Employer.class, jboss.getId());
                                                                        
    13
    jboss.setVers(new Integer(1));
                                                                  
    14
    s.getTransaction().begin();
                                          
    15
    s.merge(jboss);
    3
    baz.setDefaults();
    3
    baz.setDefaults();
    18
    cleanup();
    Differences
    Expression1Expression2Difference
    setDefaultscleanupMETHOD_INVOCATION_NAME_MISMATCH
    bazMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression baz.setDefaults() 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 baz.setDefaults() 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();
    4
    s.save(baz);
                                  
    5
    s.flush();
    5
    s.flush();
    6
    s.clear();
    Differences
    Expression1Expression2Difference
    flushclearMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.classic.Sessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    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
    Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    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.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    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
    Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    5
    s.getTransaction().commit();
    7
    s.close();
    7
    s.close();
    17
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.classic.Sessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    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.flush();
    10
    s.flush();
    12
    s.clear();
    Differences
    Expression1Expression2Difference
    flushclearMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.classic.Sessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    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
    Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    12
    s.clear();
    11
    s.connection().commit();
    11
    s.connection().commit();
    11
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    connectiongetTransactionMETHOD_INVOCATION_NAME_MISMATCH
    java.sql.Connectionorg.hibernate.TransactionVARIABLE_TYPE_MISMATCH
    org.hibernate.classic.Sessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    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
    Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    11
    s.getTransaction().commit();
    12
    s.close();
                                
    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
    baz = (Baz)s.load(Baz.class, baz.getCode());
    14
    baz = (Baz)s.load(Baz.class, baz.getCode());
    Preondition Violations
    Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                              
    15
    s.delete(baz);
    15
    s.delete(baz);
    10
    s.delete(otherJboss);
    Differences
    Expression1Expression2Difference
    bazotherJbossVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.ops.EmployerVARIABLE_TYPE_MISMATCH
    org.hibernate.classic.Sessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.ops.Employer of variable otherJboss
    • Make classes org.hibernate.test.legacy.Baz and org.hibernate.test.ops.Employer extend a common superclass
    Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    10
    s.delete(otherJboss);
    16
    s.flush();
                                
    17
    s.connection().commit();
    17
    s.connection().commit();
    16
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    connectiongetTransactionMETHOD_INVOCATION_NAME_MISMATCH
    java.sql.Connectionorg.hibernate.TransactionVARIABLE_TYPE_MISMATCH
    org.hibernate.classic.Sessionorg.hibernate.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    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
    Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    16
    s.getTransaction().commit();
    18
    s.close();
                                
    Precondition Violations (22)
    Row Violation
    1Expression baz.setDefaults() is a void method call, and thus it cannot be parameterized
    2Expression cleanup() is a void method call, and thus it cannot be parameterized
    3Expression baz.setDefaults() is a void method call, and thus it cannot be parameterized
    4Expression cleanup() is a void method call, and thus it cannot be parameterized
    5Expression s.flush() is a void method call, and thus it cannot be parameterized
    6Expression s.clear() is a void method call, and thus it cannot be parameterized
    7Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    8Type java.sql.Connection of variable s.connection() does not match with type org.hibernate.Transaction of variable s.getTransaction()
    9Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    10Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    11Unmatched statement s=openSession(); cannot be moved before or after the extracted code, 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 s.clear() is a void method call, and thus it cannot be parameterized
    14Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    15Type java.sql.Connection of variable s.connection() does not match with type org.hibernate.Transaction of variable s.getTransaction()
    16Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    17Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.ops.Employer of variable otherJboss
    20Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s
    21Type java.sql.Connection of variable s.connection() does not match with type org.hibernate.Transaction of variable s.getTransaction()
    22Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s