Session s = openSession(); Transaction t = s.beginTransaction(); Multi multi = new Multi(); multi.setExtraProp("extra"); Long id = (Long) s.save(multi); assertTrue( id!=null ); s.delete(multi); t.commit(); s.close();
Session session = openSession(); Transaction tx = session.beginTransaction(); MainObject mo = ( MainObject ) session.load( MainObject.class, generatedId ); Object2 toAdd = new Object2(); toAdd.setDummy( "test" ); //toAdd should now be saved by cascade mo.setObj2( toAdd ); tx.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/MultiTableTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/OneToOneCacheTest.java
Method name: void testMultiTableNativeId() Method name: void addObject2()
Number of AST nodes: 9 Number of AST nodes: 8
1
Session s = openSession();
1
Session session = openSession();
2
		Transaction t = s.beginTransaction();
2
		Transaction tx = session.beginTransaction();
3
		Multi multi = new Multi();
3
		M
4
		multi.setExtraProp("extra"
4
ainObject mo =
5
);
5
				( MainObject ) session.load( MainObject.class, generatedId );
6
		Long id = (Long) s.save(multi);
6
		
7
		assertTrue( id!=null
7
Object2 toAdd = new Object2();
8
 );
8
		toAdd.setDummy( "test" );
9
		s.delete(multi
9
		//toAdd should now be saved by cascade
10
);
10
		mo.setObj2( toAdd );
11
		t.commit();
11
		tx.commit();
12
		s.close();
12
		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 comparisons54
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                      
    1
    Session session = openSession();
    1
    Session s = openSession();
                                                          
    2
    Transaction t = s.beginTransaction();
    2
    Transaction t = s.beginTransaction();
    2
    Transaction tx = session.beginTransaction();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    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 session
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    2
    Transaction tx = session.beginTransaction();
                                                                                                                                                    
    3
    MainObject mo = (MainObject)session.load(MainObject.class, generatedId);
    3
    Multi multi = new Multi();
                                                          
                                                                  
    4
    Object2 toAdd = new Object2();
    4
    multi.setExtraProp("extra");
                                                                  
                                                        
    5
    toAdd.setDummy("test");
    5
    Long id = (Long)s.save(multi);
                                                                  
                                              
    6
    mo.setObj2(toAdd);
    6
    assertTrue(id != null);
                                                        
    7
    s.delete(multi);
                                          
    8
    t.commit();
    8
    t.commit();
    7
    tx.commit();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    7
    tx.commit();
    9
    s.close();
    9
    s.close();
    8
    session.close();
    Differences
    Expression1Expression2Difference
    ssessionVARIABLE_NAME_MISMATCH
    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 session
    • Make classes org.hibernate.classic.Session and org.hibernate.Session extend a common superclass
    8
    session.close();
    Precondition Violations (2)
    Row Violation
    1Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable session
    2Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable session