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 statements9
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment6
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession(new PropertyInterceptor());
    1
    Session s = openSession(new PropertyInterceptor());
    1
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    openSession(new PropertyInterceptor())openSession()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression openSession(new PropertyInterceptor()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression openSession() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    Session s = openSession();
    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.SessionSUBCLASS_TYPE_MISMATCH
    2
    Transaction txn = s.beginTransaction();
                                                                        
    3
    Fum fum = new Fum(fumKey("fum"));
    Preondition Violations
    Unmatched statement Fum fum=new Fum(fumKey("fum")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    Fum fum = new Fum(fumKey("fum"));
    3
    User u = new User("Gavin", "nivag");
    3
    User u = new User("Gavin", "nivag");
    Preondition Violations
    Unmatched statement User u=new User("Gavin","nivag"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                            
                                                          
    4
    fum.setFum("fee fi fo");
    Preondition Violations
    Unmatched statement fum.setFum("fee fi fo"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    fum.setFum("fee fi fo");
    4
    s.persist(u);
    4
    s.persist(u);
    Preondition Violations
    Unmatched statement s.persist(u); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
                                                    
    5
    Fumm fumm = new Fumm();
    5
    u.setPassword("vagni");
    5
    u.setPassword("vagni");
    Preondition Violations
    Unmatched statement u.setPassword("vagni"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                        
                                            
    6
    fumm.setFum(fum);
    Preondition Violations
    Unmatched statement fumm.setFum(fum); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6
    fumm.setFum(fum);
                                    
    7
    s.save(fumm);
    Preondition Violations
    Unmatched statement s.save(fumm); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    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.SessionSUBCLASS_TYPE_MISMATCH
    9
    s.close();
    8
    s = openSession();
    8
    s = openSession();
    10
    s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    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.SessionSUBCLASS_TYPE_MISMATCH
    11
    txn = s.beginTransaction();
    10
    u = (User)s.get(User.class, "Gavin");
    10
    u = (User)s.get(User.class, "Gavin");
    Preondition Violations
    Unmatched statement u=(User)s.get(User.class,"Gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    11
    assertNotNull(u.getCreated());
                                                                        
                                                                                                    
    12
    fumm = (Fumm)s.load(Fumm.class, fumKey("fum"));
    Preondition Violations
    Unmatched statement fumm=(Fumm)s.load(Fumm.class,fumKey("fum")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    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.SessionSUBCLASS_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
    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.SessionSUBCLASS_TYPE_MISMATCH
    15
    s.close();
    Precondition Violations (13)
    Row Violation
    1Expression openSession(new PropertyInterceptor()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression openSession() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement Fum fum=new Fum(fumKey("fum")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement User u=new User("Gavin","nivag"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement fum.setFum("fee fi fo"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement s.persist(u); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement u.setPassword("vagni"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement fumm.setFum(fum); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9Unmatched statement s.save(fumm); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement u=(User)s.get(User.class,"Gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement fumm=(Fumm)s.load(Fumm.class,fumKey("fum")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Type org.hibernate.test.interceptor.User of variable u does not match with type org.hibernate.test.legacy.Fumm of variable fumm
    13Clone fragment #1 returns variable s with type org.hibernate.Session , while Clone fragment #2 returns variable s with type org.hibernate.classic.Session