final StatefulInterceptor statefulInterceptor = new StatefulInterceptor(); Session s = openSession( statefulInterceptor ); statefulInterceptor.setSession(s); 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(); List logs = s.createCriteria(Log.class).list(); assertEquals( 2, logs.size() ); s.delete(u); s.createQuery( "delete from Log" ).executeUpdate(); t.commit(); s.close();
Session s = openSession(); Vetoer v = new Vetoer(); v.setStrings( new String[] { "foo", "bar", "baz" } ); s.save(v); Serializable id = s.save(v); v.getStrings()[1] = "osama"; s.flush(); s.connection().commit(); s.close(); s = openSession(); v = (Vetoer) s.load(Vetoer.class, id); assertTrue( "serializable type", v.getStrings()[1].equals("osama") ); s.delete(v); s.delete(v); s.flush(); s.connection().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/FooBarTest.java
Method name: void testStatefulIntercept() Method name: void testSerializableType()
Number of AST nodes: 17 Number of AST nodes: 17
1
final StatefulInterceptor statefulInterceptor = new StatefulInterceptor();
2
		Session s = openSession( statefulInterceptor );
3
		statefulInterceptor.setSession(s);
4
		Transaction t = s.beginTransaction();
5
		User u = new User("Gavin", "nivag");
6
		s.persist(u);
7
		u.setPassword("vagni");
8
		t
1
Session s = openSession();
2
		Vetoer v = new Vetoer();
3
		v.setStrings( new String[] { "foo", "bar", "baz" } );
4
		s.save(v); Serializable id = s.save(v);
5
		v.getStrings()[1] = "osama";
6
		s.flush();
9
.commit();
7
		s.connection().commit();
10
		s.close();
8
		s.close();
11
		s = openSession();
9
		s = openSession();
12
		t = s.beginTransaction();
10
		v = 
13
		List logs = s.createCriteria(Log.class).list();
14
		assertEquals( 2, logs.size(
11
(Vetoer) s.load(Vetoer.class, id);
15
) );
12
		assertTrue( "serializable type", v.getStrings()[1].equals("osama") );
16
		s.delete(u);
13
		s.delete(v);
17
		s.createQuery( "delete from Log" ).executeUpdate();
18
		t
14
 s.delete(v);
15
		s.flush();
19
.commit();
16
		s.connection().commit();
20
		s.close();
17
		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 comparisons229
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment11
    Number of unmapped statements in the second code fragment11
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    final StatefulInterceptor statefulInterceptor = new StatefulInterceptor();
                                                                                                                                                          
    2
    Session s = openSession(statefulInterceptor);
    2
    Session s = openSession(statefulInterceptor);
    1
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    openSession(statefulInterceptor)openSession()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression openSession(statefulInterceptor) 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
    Vetoer v = new Vetoer();
                                                                                                      
    3
    v.setStrings(new String[] {"foo", "bar", "baz"});
    Preondition Violations
    Unmatched statement v.setStrings(new String[]{"foo","bar","baz"}); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    v.setStrings(new String[] {"foo", "bar", "baz"});
    3
    statefulInterceptor.setSession(s);
    3
    statefulInterceptor.setSession(s);
    Preondition Violations
    Unmatched statement statefulInterceptor.setSession(s); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                              
                              
    4
    s.save(v);
    Preondition Violations
    Unmatched statement s.save(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    s.save(v);
    4
    Transaction t = s.beginTransaction();
    4
    Transaction t = s.beginTransaction();
    Preondition Violations
    Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
                                                              
    5
    Serializable id = s.save(v);
    Preondition Violations
    Unmatched statement Serializable id=s.save(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    Serializable id = s.save(v);
    5
    User u = new User("Gavin", "nivag");
    5
    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
                                                                            
                                                              
    6
    v.getStrings()[1] = "osama";
    6
    s.persist(u);
    6
    s.persist(u);
    7
    s.flush();
    Differences
    Expression1Expression2Difference
    persistflushMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    s.persist(u)s.flush()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s.persist(u) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.persist(u) is a void method call, and thus it cannot be parameterized
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression s.persist(u) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.persist(u) is a void method call, and thus it cannot be parameterized
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    7
    s.flush();
    7
    u.setPassword("vagni");
    7
    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
                                                        
                                                          
    8
    s.connection().commit();
    Preondition Violations
    Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    s.connection().commit();
    8
    t.commit();
    8
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                
    9
    s.close();
    9
    s.close();
    9
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    9
    s.close();
    10
    s = openSession();
    10
    s = openSession();
    10
    s = openSession();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    10
    s = openSession();
                                                                                
    11
    v = (Vetoer)s.load(Vetoer.class, id);
    Preondition Violations
    Unmatched statement v=(Vetoer)s.load(Vetoer.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    v = (Vetoer)s.load(Vetoer.class, id);
    11
    t = s.beginTransaction();
    11
    t = s.beginTransaction();
    Preondition Violations
    Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                          
                                                                                                                                                
    12
    assertTrue("serializable type", v.getStrings()[1].equals("osama"));
    12
    List logs = s.createCriteria(Log.class).list();
    12
    List logs = s.createCriteria(Log.class).list();
    Preondition Violations
    Unmatched statement List logs=s.createCriteria(Log.class).list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                      
                                    
    13
    s.delete(v);
    Preondition Violations
    Unmatched statement s.delete(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    s.delete(v);
    13
    assertEquals(2, logs.size());
                                                                    
    14
    s.delete(u);
    14
    s.delete(u);
    14
    s.delete(v);
    Differences
    Expression1Expression2Difference
    uvVARIABLE_NAME_MISMATCH
    org.hibernate.test.interceptor.Userorg.hibernate.test.legacy.VetoerVARIABLE_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.Vetoer of variable v
    • Make classes org.hibernate.test.interceptor.User and org.hibernate.test.legacy.Vetoer extend a common superclass
    14
    s.delete(v);
                                
    15
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    s.flush();
    15
    s.createQuery("delete from Log").executeUpdate();
    15
    s.createQuery("delete from Log").executeUpdate();
    Preondition Violations
    Unmatched statement s.createQuery("delete from Log").executeUpdate(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                              
                                                            
    16
    s.connection().commit();
    Preondition Violations
    Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    s.connection().commit();
    16
    t.commit();
    16
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                  
    17
    s.close();
    17
    s.close();
    17
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionSUBCLASS_TYPE_MISMATCH
    17
    s.close();
    Precondition Violations (29)
    Row Violation
    1Expression openSession(statefulInterceptor) 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 v.setStrings(new String[]{"foo","bar","baz"}); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement statefulInterceptor.setSession(s); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement s.save(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement Serializable id=s.save(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched 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
    9Expression s.persist(u) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression s.persist(u) is a void method call, and thus it cannot be parameterized
    12Expression s.flush() is a void method call, and thus it cannot be parameterized
    13Expression s.persist(u) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression s.persist(u) is a void method call, and thus it cannot be parameterized
    16Expression s.flush() is a void method call, and thus it cannot be parameterized
    17Unmatched statement u.setPassword("vagni"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    18Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    20Unmatched statement v=(Vetoer)s.load(Vetoer.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement List logs=s.createCriteria(Log.class).list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Unmatched statement s.delete(v); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24Type org.hibernate.test.interceptor.User of variable u does not match with type org.hibernate.test.legacy.Vetoer of variable v
    25Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    26Unmatched statement s.createQuery("delete from Log").executeUpdate(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    27Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    28Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    29Clone fragment #1 returns variable s with type org.hibernate.Session , while Clone fragment #2 returns variable s with type org.hibernate.classic.Session