Session session = openSession(); Transaction txn = session.beginTransaction(); Mammal m1 = new Mammal(); m1.setBodyWeight( 11f ); m1.setDescription( "Mammal #1" ); session.save( m1 ); Mammal m2 = new Mammal(); m2.setBodyWeight( 9f ); m2.setDescription( "Mammal #2" ); m2.setMother( m1 ); session.save( m2 ); txn.commit(); session.close(); createdAnimalIds.add( m1.getId() ); createdAnimalIds.add( m2.getId() );
Session s = openSession(); s.beginTransaction(); Item item = new Item(); item.setName( "dummy" ); s.persist( item ); s.getTransaction().commit(); s.close(); Long id = item.getId(); s = openSession(); s.beginTransaction(); s.delete( item ); item = ( Item ) s.get( Item.class, id ); s.getTransaction().commit(); s.close(); assertNull( "expecting removed entity to be returned as null from get()", item );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/jpa/removed/RemovedEntityTest.java
Method name: void createTestBaseData() Method name: void testRemoveThenGet()
Number of AST nodes: 15 Number of AST nodes: 15
1
Session session = openSession();
1
Session s = openSession();
2
		Transaction txn = session.beginTransaction();
2
		s.beginTransaction();
3

3
		Mammal m1 = new Mammal();
4
		Item item = new Item();
4
		m1.setBodyWeight( 11f
5
		item.setName( "dummy" );
5
 );
6
		s.persist( item );
6
		m1.setDescription( "Mammal #1" );
7
		s.getTransaction().commit();
8

7
		session.save( m1 );
9
		s
8
		Mammal m2 = new Mammal();
9
		m2.setBodyWeight( 9f 
10
.close();
11
		Long id = item.getId();
10
);
12
		s = openSession();
11
		m2.setDescription( "Mammal #2" );
13
		s.beginTransaction();
12
		m2.setMother( m1 );
14
		s.delete( item );
15

13
		session.save( m2 );
16
		item = ( Item ) s.get( Item.class, id );
17

14
		txn.commit();
18
		s.getTransaction().commit();
15
		session.close();
19
		s.close();
16
		createdAnimalIds.add( m1.getId() );
17
		createdAnimalIds.add( m2.getId()
18
 );
20
		assertNull( "expecting removed entity to be returned as null from get()", item );
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 comparisons225
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment13
    Number of unmapped statements in the second code fragment13
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session session = openSession();
    1
    Session session = openSession();
    1
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_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();
    2
    Transaction txn = session.beginTransaction();
    2
    Transaction txn = session.beginTransaction();
    Preondition Violations
    Unmatched statement Transaction txn=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                
                                                    
    3
    Item item = new Item();
    3
    Mammal m1 = new Mammal();
                                                        
                                                      
    4
    item.setName("dummy");
    Preondition Violations
    Unmatched statement item.setName("dummy"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    item.setName("dummy");
    4
    m1.setBodyWeight(11f);
    4
    m1.setBodyWeight(11f);
    Preondition Violations
    Unmatched statement m1.setBodyWeight(11f); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                      
                                          
    5
    s.persist(item);
    Preondition Violations
    Unmatched statement s.persist(item); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    s.persist(item);
    5
    m1.setDescription("Mammal #1");
    5
    m1.setDescription("Mammal #1");
    Preondition Violations
    Unmatched statement m1.setDescription("Mammal #1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                        
                                                                  
    6
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    s.getTransaction().commit();
    6
    session.save(m1);
    6
    session.save(m1);
    Preondition Violations
    Unmatched statement session.save(m1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                            
    7
    Mammal m2 = new Mammal();
                                                        
                                                    
    8
    Long id = item.getId();
    8
    m2.setBodyWeight(9f);
    8
    m2.setBodyWeight(9f);
    Preondition Violations
    Unmatched statement m2.setBodyWeight(9f); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                    
                                          
    9
    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
    9
    s = openSession();
    9
    m2.setDescription("Mammal #2");
    9
    m2.setDescription("Mammal #2");
    Preondition Violations
    Unmatched statement m2.setDescription("Mammal #2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                        
                                                      
    10
    s.beginTransaction();
    10
    m2.setMother(m1);
    10
    m2.setMother(m1);
    Preondition Violations
    Unmatched statement m2.setMother(m1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                              
                                          
    11
    s.delete(item);
    11
    session.save(m2);
    11
    session.save(m2);
    Preondition Violations
    Unmatched statement session.save(m2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                              
                                                                            
    12
    item = (Item)s.get(Item.class, id);
    12
    txn.commit();
    12
    txn.commit();
    Preondition Violations
    Unmatched statement txn.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                      
    13
    session.close();
    13
    session.close();
    7
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    7
    s.close();
                                                                    
    13
    s.getTransaction().commit();
                                
    14
    s.close();
    14
    createdAnimalIds.add(m1.getId());
                                                                              
                                                                                                                                                                        
    15
    assertNull("expecting removed entity to be returned as null from get()", item);
    15
    createdAnimalIds.add(m2.getId());
                                                                              
    Precondition Violations (14)
    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 Transaction txn=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement item.setName("dummy"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement m1.setBodyWeight(11f); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement s.persist(item); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement m1.setDescription("Mammal #1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement session.save(m1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement m2.setBodyWeight(9f); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement m2.setDescription("Mammal #2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Unmatched statement m2.setMother(m1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13Unmatched statement session.save(m2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement txn.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted