if ( translator.hasProjection() ) { Type[] types = translator.getProjectedTypes(); result = new Object[types.length]; String[] columnAliases = translator.getProjectedColumnAliases(); for ( int i=0; i<result.length; i++ ) { result[i] = types[i].nullSafeGet(rs, columnAliases[i], session, null); } aliases = translator.getProjectedAliases(); } else { result = row; aliases = userAliases; }
int length = collectionFromElements.size(); collectionPersisters = new QueryableCollection[length]; collectionOwners = new int[length]; collectionSuffixes = new String[length]; for ( int i=0; i<length; i++ ) { FromElement collectionFromElement = (FromElement) collectionFromElements.get(i); collectionPersisters[i] = collectionFromElement.getQueryableCollection(); collectionOwners[i] = fromElementList.indexOf( collectionFromElement.getOrigin() ); // collectionSuffixes[i] = collectionFromElement.getColumnAliasSuffix(); // collectionSuffixes[i] = Integer.toString( i ) + "_"; collectionSuffixes[i] = collectionFromElement.getCollectionSuffix(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/loader/criteria/CriteriaLoader.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/loader/hql/QueryLoader.java
Method name: Object getResultColumnOrRow(Object[], ResultTransformer, ResultSet, SessionImplementor) Method name: void initialize(SelectClause)
Number of AST nodes: 9 Number of AST nodes: 9
1
if ( translator.hasProjection() ) {
1
i
2
			Type[] types = translator.getProjectedTypes();
3
			result = new Object[types.length];
4
			String[] columnAliases = translator.getProjectedColumnAliases()
2
nt length = collectionFromElements.size();
3
			collectionPersisters = new QueryableCollection[length];
4
			collectionOwners = new int[length];
5
;
5
			collectionSuffixes = new String[length];
6
			for ( int i=0; i<result.length; i++ ) {
6
			for ( int i=0; i<length; i++ ) {
7
				result[i] = types[i].nullSafeGet(rs, columnAliases[i], session, null);
7
				
8
			}
9
			aliases = translator.getProjectedAliases();
10
		}
11
		else {
12
			result = row;
13
			aliases = userAliases
8
FromElement collectionFromElement = (FromElement) collectionFromElements.get(i);
9
				collectionPersisters[i] = collectionFromElement.getQueryableCollection();
10
				collectionOwners[i] = fromElementList.indexOf( collectionFromElement.getOrigin() );
11
//				collectionSuffixes[i] = collectionFromElement.getColumnAliasSuffix();
12
//				collectionSuffixes[i] = Integer.toString( i ) + "_";
14
;
13
				collectionSuffixes[i] = collectionFromElement.getCollectionSuffix();
15
		}
14
			}
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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons35
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment7
    Time elapsed for statement mapping (ms)3.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    4
    Type[] types = translator.getProjectedTypes();
                                                                                                  
    5
    result = new Object[types.length];
                                                                          
    6
    String[] columnAliases = translator.getProjectedColumnAliases();
                                                                                                                                      
                                                                                            
    9
    int length = collectionFromElements.size();
                                                                                                                      
    10
    collectionPersisters = new QueryableCollection[length];
    Preondition Violations
    Unmatched statement collectionPersisters=new QueryableCollection[length]; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10
    collectionPersisters = new QueryableCollection[length];
                                                                              
    11
    collectionOwners = new int[length];
    Preondition Violations
    Unmatched statement collectionOwners=new int[length]; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11
    collectionOwners = new int[length];
    7
    for (int i = 0; i < result.length; i++)
    7
    for (int i = 0; i < result.length; i++)
    13
    for (int i = 0; i < length; i++)
    Differences
    Expression1Expression2Difference
    result.lengthlengthTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression result.length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13
    for (int i = 0; i < length; i++)
    8
    result[i] = types[i].nullSafeGet(rs, columnAliases[i], session, null);
    8
    result[i] = types[i].nullSafeGet(rs, columnAliases[i], session, null);
    Preondition Violations
    Unmatched statement result[i]=types[i].nullSafeGet(rs,columnAliases[i],session,null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement result[i]=types[i].nullSafeGet(rs,columnAliases[i],session,null); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                                                                            
                                                                                                                                                                      
    14
    FromElement collectionFromElement = (FromElement)collectionFromElements.get(i);
    Preondition Violations
    Unmatched statement FromElement collectionFromElement=(FromElement)collectionFromElements.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    FromElement collectionFromElement = (FromElement)collectionFromElements.get(i);
                                                                                                                                                          
    15
    collectionPersisters[i] = collectionFromElement.getQueryableCollection();
    Preondition Violations
    Unmatched statement collectionPersisters[i]=collectionFromElement.getQueryableCollection(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    collectionPersisters[i] = collectionFromElement.getQueryableCollection();
                                                                                                                                                                          
    16
    collectionOwners[i] = fromElementList.indexOf(collectionFromElement.getOrigin());
    Preondition Violations
    Unmatched statement collectionOwners[i]=fromElementList.indexOf(collectionFromElement.getOrigin()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    collectionOwners[i] = fromElementList.indexOf(collectionFromElement.getOrigin());
                                                                                                                                                
    17
    collectionSuffixes[i] = collectionFromElement.getCollectionSuffix();
    Preondition Violations
    Unmatched statement collectionSuffixes[i]=collectionFromElement.getCollectionSuffix(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    collectionSuffixes[i] = collectionFromElement.getCollectionSuffix();
    9
    aliases = translator.getProjectedAliases();
                                                                                            
    10
    result = row;
                                  
    11
    aliases = userAliases;
    11
    aliases = userAliases;
    12
    collectionSuffixes = new String[length];
    Differences
    Expression1Expression2Difference
    aliasescollectionSuffixesVARIABLE_NAME_MISMATCH
    userAliasesnew String[length]TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new String[length] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    collectionSuffixes = new String[length];
    Precondition Violations (12)
    Row Violation
    1Unmatched statement collectionPersisters=new QueryableCollection[length]; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement collectionOwners=new int[length]; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression result.length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement result[i]=types[i].nullSafeGet(rs,columnAliases[i],session,null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement result[i]=types[i].nullSafeGet(rs,columnAliases[i],session,null); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    7Unmatched statement FromElement collectionFromElement=(FromElement)collectionFromElements.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement collectionPersisters[i]=collectionFromElement.getQueryableCollection(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement collectionOwners[i]=fromElementList.indexOf(collectionFromElement.getOrigin()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement collectionSuffixes[i]=collectionFromElement.getCollectionSuffix(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Expression new String[length] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Clone fragment #1 returns variables i, aliases , while Clone fragment #2 returns variables i