Session s = openSession( new PropertyInterceptor() ); Transaction t = s.beginTransaction(); User u = new User("Gavin", "nivag"); s.persist(u); u.setPassword("vagni"); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); u = (User) s.get(User.class, "Gavin"); assertNotNull( u.getCreated() ); assertNotNull( u.getLastUpdated() ); s.delete(u); t.commit(); s.close();
Session s = openSession(); Transaction txn = s.beginTransaction(); Fum fum = new Fum( fumKey("fum") ); fum.setFum("fee fi fo"); //s.save(fum); Fumm fumm = new Fumm(); fumm.setFum(fum); s.save(fumm); txn.commit(); s.close(); s = openSession(); txn = s.beginTransaction(); fumm = (Fumm) s.load( Fumm.class, fumKey("fum") ); //s.delete( fumm.getFum() ); s.delete(fumm); txn.commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FumTest.java
Method name: void testPropertyIntercept() Method name: void testCompositeIDOneToOne()
Number of AST nodes: 15 Number of AST nodes: 15
1
Session s = openSession( new PropertyInterceptor() );
1
Session s = openSession();
2
		Transaction t = s.beginTransaction();
2
		Transaction txn = s.beginTransaction();
3
		User u = new User("Gavin", "nivag");
3
		
4
		s.persist(u);
5
		u.setPassword("vagni"
4
Fum fum = new Fum( fumKey("fum") );
5
		fum.setFum("fee fi fo");
6
		//s.save(fum);
7
		Fumm fumm = new Fumm();
8
		fumm.setFum(fum);
6
);
9
		s.save(fumm);
7
		t.commit();
10
		txn.commit();
8
		s.close();
11
		s.close();
9
		s = openSession();
12
		s = openSession();
10
		t = s.beginTransaction();
13
		txn = s.beginTransaction();
11
		u = (User) s.get(User.class, "Gavin");
14
		
12
		assertNotNull( u.getCreated() );
13
		assertNotNull( u.getLastUpdated
15
fumm = (Fumm) s.load( Fumm.class, fumKey("fum") );
14
() );
16
		//s.delete( fumm.getFum() );
15
		s.delete(u);
17
		s.delete(fumm);
16
		t.commit();
18
		txn.commit();
17
		s.close();
19
		s.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 comparisons125
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment8
    Number of unmapped statements in the second code fragment8
    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(new PropertyInterceptor());
                                                                                                            
    2
    Transaction t = s.beginTransaction();
    2
    Transaction t = s.beginTransaction();
    2
    Transaction txn = s.beginTransaction();
    Differences
    Expression1Expression2Difference
    ttxnVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    2
    Transaction txn = s.beginTransaction();
                                                                        
    3
    Fum fum = new Fum(fumKey("fum"));
    3
    User u = new User("Gavin", "nivag");
                                                                            
                                                          
    4
    fum.setFum("fee fi fo");
    4
    s.persist(u);
                                    
                                                    
    5
    Fumm fumm = new Fumm();
    5
    u.setPassword("vagni");
                                                        
                                            
    6
    fumm.setFum(fum);
                                    
    7
    s.save(fumm);
    6
    t.commit();
    6
    t.commit();
    8
    txn.commit();
    Differences
    Expression1Expression2Difference
    ttxnVARIABLE_NAME_MISMATCH
    8
    txn.commit();
    7
    s.close();
    7
    s.close();
    9
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    9
    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
                                          
                                            
    10
    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
    10
    s = openSession();
    9
    t = s.beginTransaction();
    9
    t = s.beginTransaction();
    11
    txn = s.beginTransaction();
    Differences
    Expression1Expression2Difference
    ttxnVARIABLE_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    11
    txn = s.beginTransaction();
    10
    u = (User)s.get(User.class, "Gavin");
                                                                                
    11
    assertNotNull(u.getCreated());
                                                                        
                                                                                                    
    12
    fumm = (Fumm)s.load(Fumm.class, fumKey("fum"));
    12
    assertNotNull(u.getLastUpdated());
                                                                                
    13
    s.delete(u);
    13
    s.delete(u);
    13
    s.delete(fumm);
    Differences
    Expression1Expression2Difference
    ufummVARIABLE_NAME_MISMATCH
    org.hibernate.test.interceptor.Userorg.hibernate.test.legacy.FummVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.interceptor.User of variable u does not match with type org.hibernate.test.legacy.Fumm of variable fumm
    • Make classes org.hibernate.test.interceptor.User and org.hibernate.test.legacy.Fumm extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    13
    s.delete(fumm);
    14
    t.commit();
    14
    t.commit();
    14
    txn.commit();
    Differences
    Expression1Expression2Difference
    ttxnVARIABLE_NAME_MISMATCH
    14
    txn.commit();
    15
    s.close();
    15
    s.close();
    15
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    15
    s.close();
    Precondition Violations (8)
    Row Violation
    1Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    2Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    3Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    6Type org.hibernate.test.interceptor.User of variable u does not match with type org.hibernate.test.legacy.Fumm of variable fumm
    7Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    8Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s