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(); s.beginTransaction(); Customer cust = new Customer( "Acme, Inc." ); Order order = new Order( new Order.Id( cust, 1 ) ); cust.getOrders().add( order ); s.save( cust ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); try { cust = ( Customer ) s.get( Customer.class, cust.getId() ); } catch( OverflowCondition overflow ) { fail( "get()/load() caused overflow condition" ); } s.delete( cust ); s.getTransaction().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/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
Method name: void testStatefulIntercept() Method name: void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected()
Number of AST nodes: 17 Number of AST nodes: 15
1
final StatefulInterceptor statefulInterceptor = new StatefulInterceptor();
2
		Session s = openSession( statefulInterceptor );
1
Session s = openSession();
3
		statefulInterceptor.setSession(s);
2
		s.beginTransaction();
3

4
		Transaction t = s.beginTransaction();
4
		Customer cust = new Customer( "Acme, Inc." );
5
		User u = new User("Gavin", "nivag");
5
		Order order = new Order( new Order.Id( cust, 1 ) );
6
		s.persist(u
6
		cust.getOrders().add( order );
7
);
7
		s.save( cust );
8
		u.setPassword("vagni");
8
		
9
		t.commit();
9
s.getTransaction().commit();
10
		s.close();
10
		s.close();
11

11
		s = openSession();
12
		s = openSession();
12
		t = s.beginTransaction();
13
		s.beginTransaction();
13
		List logs = s.createCriteria(Log.class).list();
14
		
14
		assertEquals( 2, logs.size() );
15
		s.delete(u);
16
		s.createQuery( "delete from Log" ).executeUpdate(
15
try {
16
			cust = ( Customer ) s.get( Customer.class, cust.getId() );
17
		}
18
		catch( OverflowCondition overflow ) {
19
			fail( "get()/load() caused overflow condition" );
20
		}
17
);
21
		s.delete( cust );
18
		t.commit();
22
		s.getTransaction().commit();
19
		s.close();
23
		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 comparisons169
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment10
    Number of unmapped statements in the second code fragment8
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    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
    openSession(statefulInterceptor)openSession()ARGUMENT_NUMBER_MISMATCH
    1
    Session s = openSession();
                                                    
    2
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    s.beginTransaction();
                                                                                            
    3
    Customer cust = new Customer("Acme, Inc.");
    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
    Order order = new Order(new Order.Id(cust, 1));
    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
    cust.getOrders().add(order);
    5
    User u = new User("Gavin", "nivag");
                                                                            
                                    
    6
    s.save(cust);
    Preondition Violations
    Unmatched statement s.save(cust); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    s.save(cust);
    6
    s.persist(u);
    6
    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
                                    
    7
    u.setPassword("vagni");
                                                        
    8
    t.commit();
    8
    t.commit();
    7
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    ts.getTransaction()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    s.getTransaction().commit();
    9
    s.close();
    8
    s.close();
    10
    s = openSession();
    9
    s = openSession();
                                                      
    10
    s.beginTransaction();
                  
    11
    try
                                                                                                                
    12
    cust = (Customer)s.get(Customer.class, cust.getId());
    Preondition Violations
    Unmatched statement cust=(Customer)s.get(Customer.class,cust.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    cust = (Customer)s.get(Customer.class, cust.getId());
    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
    List logs = s.createCriteria(Log.class).list();
                                                                                                      
    13
    assertEquals(2, logs.size());
                                                                    
    14
    s.delete(u);
    14
    s.delete(u);
    13
    s.delete(cust);
    Differences
    Expression1Expression2Difference
    ucustVARIABLE_NAME_MISMATCH
    org.hibernate.test.interceptor.Userorg.hibernate.test.keymanytoone.bidir.component.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.interceptor.User of variable u does not match with type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust
    • Make classes org.hibernate.test.interceptor.User and org.hibernate.test.keymanytoone.bidir.component.Customer extend a common superclass
    13
    s.delete(cust);
    15
    s.createQuery("delete from Log").executeUpdate();
                                                                                                              
    16
    t.commit();
    16
    t.commit();
    14
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    ts.getTransaction()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    s.getTransaction().commit();
    17
    s.close();
    15
    s.close();
    Precondition Violations (10)
    Row Violation
    1Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement statefulInterceptor.setSession(s); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched 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
    4Unmatched statement s.save(cust); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement s.persist(u); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Unmatched statement cust=(Customer)s.get(Customer.class,cust.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Type org.hibernate.test.interceptor.User of variable u does not match with type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust
    10Expression s.getTransaction() cannot be parameterized, because it has dependencies to/from statements that will be extracted