ArrayList iters = new ArrayList(); iters.add( getPropertyClosureIterator() ); iters.add( subclassProperties.iterator() ); for ( int i=0; i<subclassJoins.size(); i++ ) { Join join = (Join) subclassJoins.get(i); iters.add( join.getPropertyIterator() ); } return new JoinedIterator(iters);
Session session = openSession(); Transaction txn = session.beginTransaction(); for ( int i = 0; i < createdAnimalIds.size(); i++ ) { Animal animal = ( Animal ) session.load( Animal.class, ( Long ) createdAnimalIds.get( i ) ); session.delete( animal ); } txn.commit(); session.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/mapping/PersistentClass.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java
Method name: Iterator getSubclassPropertyClosureIterator() Method name: void destroyTestBaseData()
Number of AST nodes: 7 Number of AST nodes: 7
1
ArrayList iters = new ArrayList();
2
		iters.add( getPropertyClosureIterator() );
3
		iters.add( subclassProperties.iterator() );
1
Session session = openSession();
2
		Transaction txn = session.beginTransaction();
4
		for ( int i=0; i<subclassJoins.size(); i++ ) {
3
		for ( int i = 0; i < createdAnimalIds.size(); i++ ) {
5
			Join join = (Join) subclassJoins.get(i);
4
			Animal animal = ( Animal ) session.load( Animal.class, ( Long ) createdAnimalIds.get( i ) );
6
			iters.add( join.getPropertyIterator() );
5
			session.delete( animal );
7
		}
6
		}
8
		return new JoinedIterator(iters
7
		txn.commit();
9
);
8
		session.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.3
Clones locationClones are in different classes
Number of node comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment6
    Time elapsed for statement mapping (ms)1.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                      
    1
    Session session = openSession();
    1
    ArrayList iters = new ArrayList();
                                                                          
                                                                                                
    2
    Transaction txn = session.beginTransaction();
    2
    iters.add(getPropertyClosureIterator());
                                                                                          
    3
    iters.add(subclassProperties.iterator());
                                                                                            
    4
    for (int i = 0; i < subclassJoins.size(); i++)
    4
    for (int i = 0; i < subclassJoins.size(); i++)
    3
    for (int i = 0; i < createdAnimalIds.size(); i++)
    Differences
    Expression1Expression2Difference
    subclassJoinscreatedAnimalIdsVARIABLE_NAME_MISMATCH
    java.util.ArrayListjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.ArrayList of variable subclassJoins does not match with type java.util.List of variable createdAnimalIds
    • Make classes java.util.ArrayList and java.util.List extend a common superclass
    3
    for (int i = 0; i < createdAnimalIds.size(); i++)
                                                                                                                                                                        
    4
    Animal animal = (Animal)session.load(Animal.class, (Long)createdAnimalIds.get(i));
    Preondition Violations
    Unmatched statement Animal animal=(Animal)session.load(Animal.class,(Long)createdAnimalIds.get(i)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    Animal animal = (Animal)session.load(Animal.class, (Long)createdAnimalIds.get(i));
                                                        
    5
    session.delete(animal);
    5
    Join join = (Join)subclassJoins.get(i);
    5
    Join join = (Join)subclassJoins.get(i);
    Preondition Violations
    Unmatched statement Join join=(Join)subclassJoins.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                    
    6
    iters.add(join.getPropertyIterator());
                                                                                      
                                    
    6
    txn.commit();
                                          
    7
    session.close();
    7
    return new JoinedIterator(iters);
    7
    return new JoinedIterator(iters);
    Preondition Violations
    Unmatched return new JoinedIterator(iters);
                                                                            
    Precondition Violations (4)
    Row Violation
    1Type java.util.ArrayList of variable subclassJoins does not match with type java.util.List of variable createdAnimalIds
    2Unmatched statement Animal animal=(Animal)session.load(Animal.class,(Long)createdAnimalIds.get(i)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement Join join=(Join)subclassJoins.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched return new JoinedIterator(iters);