String[] columnAliases; // Let return-propertys override whatever the persister has for aliases. columnAliases = ( String[] ) fieldResults.get(propertyName); if ( columnAliases==null ) { columnAliases = collectionPersister.getCollectionPropertyColumnAliases( propertyName, collectionSuffix ); } if ( columnAliases == null || columnAliases.length == 0 ) { throw new QueryException( "No column name found for property [" + propertyName + "] for alias [" + aliasName + "]", originalQueryString ); } if ( columnAliases.length != 1 ) { // TODO: better error message since we actually support composites if names are explicitly listed. throw new QueryException( "SQL queries only support properties mapped to a single column - property [" + propertyName + "] is mapped to " + columnAliases.length + " columns.", originalQueryString ); } aliasesFound++; return columnAliases[0];
String[] columnAliases; // Let return-propertys override whatever the persister has for aliases. columnAliases = (String[]) fieldResults.get( propertyName ); if ( columnAliases == null ) { columnAliases = persister.getSubclassPropertyColumnAliases( propertyName, suffix ); } if ( columnAliases == null || columnAliases.length == 0 ) { throw new QueryException( "No column name found for property [" + propertyName + "] for alias [" + aliasName + "]", originalQueryString ); } if ( columnAliases.length != 1 ) { // TODO: better error message since we actually support composites if names are explicitly listed. throw new QueryException( "SQL queries only support properties mapped to a single column - property [" + propertyName + "] is mapped to " + columnAliases.length + " columns.", originalQueryString ); } aliasesFound++; return columnAliases[0];
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java
Method name: String resolveCollectionProperties(String, String) Method name: String resolveProperties(String, String)
Number of AST nodes: 10 Number of AST nodes: 10
1
String[] columnAliases;
1
String[] columnAliases;
2
			// Let return-propertys override whatever the persister has for aliases.
2
			// Let return-propertys override whatever the persister has for aliases.
3
			columnAliases = ( String[] ) fieldResults.get(propertyName);
3
			columnAliases = (String[]) fieldResults.get( propertyName );
4
			if ( columnAliases==null ) {
4
			if ( columnAliases == null ) {
5
				columnAliases = collectionPersister.getCollectionPropertyColumnAliases( propertyName, collectionSuffix );
5
				columnAliases = persister.getSubclassPropertyColumnAliases( propertyName, suffix );
6
			}
6
			}
7
			
8
			if ( columnAliases == null || columnAliases.length == 0 ) {
7
			if ( columnAliases == null || columnAliases.length == 0 ) {
9
				throw new QueryException(
8
				throw new QueryException(
10
						"No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",
9
						"No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",
11
						originalQueryString
10
						originalQueryString
12
				);
11
				);
13
			}
12
			}
14
			if ( columnAliases.length != 1 ) {
13
			if ( columnAliases.length != 1 ) {
15
				// TODO: better error message since we actually support composites if names are explicitly listed.
14
				// TODO: better error message since we actually support composites if names are explicitly listed.
16
				throw new QueryException(
15
				throw new QueryException(
17
						"SQL queries only support properties mapped to a single column - property [" +
16
						"SQL queries only support properties mapped to a single column - property [" +
18
						propertyName + "] is mapped to " + columnAliases.length + " columns.",
17
 propertyName + "] is mapped to " + columnAliases.length + " columns.",
19
						originalQueryString
18
						originalQueryString
20
				);
19
				);
21
			}
20
			}			
22
			aliasesFound++;
21
			aliasesFound++;
23
			return columnAliases[0];
22
			return columnAliases[0];
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)1.5
Clones locationClones are declared in the same class
Number of node comparisons35
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)3.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    12
    String[] columnAliases;
    9
    String[] columnAliases;
    13
    columnAliases = (String[])fieldResults.get(propertyName);
    10
    columnAliases = (String[])fieldResults.get(propertyName);
    14
    if (columnAliases == null)
    11
    if (columnAliases == null)
                                                                                                                                                                        
    12
    columnAliases = persister.getSubclassPropertyColumnAliases(propertyName, suffix);
    Preondition Violations
    Unmatched statement columnAliases=persister.getSubclassPropertyColumnAliases(propertyName,suffix); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    columnAliases = persister.getSubclassPropertyColumnAliases(propertyName, suffix);
    15
    columnAliases = collectionPersister.getCollectionPropertyColumnAliases(propertyName, collectionSuffix);
    15
    columnAliases = collectionPersister.getCollectionPropertyColumnAliases(propertyName, collectionSuffix);
    Preondition Violations
    Unmatched statement columnAliases=collectionPersister.getCollectionPropertyColumnAliases(propertyName,collectionSuffix); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                                    
    16
    if (columnAliases == null || columnAliases.length == 0)
    13
    if (columnAliases == null || columnAliases.length == 0)
    17
    throw new QueryException("No column name found for property [" + propertyName + "] for alias [" + aliasName + "]", originalQueryString);
    14
    throw new QueryException("No column name found for property [" + propertyName + "] for alias [" + aliasName + "]", originalQueryString);
    18
    if (columnAliases.length != 1)
    15
    if (columnAliases.length != 1)
    19
    throw new QueryException("SQL queries only support properties mapped to a single column - property [" + propertyName + "] is mapped to " + columnAliases.length + " columns.", originalQueryString);
    16
    throw new QueryException("SQL queries only support properties mapped to a single column - property [" + propertyName + "] is mapped to " + columnAliases.length + " columns.", originalQueryString);
    20
    aliasesFound++;
    17
    aliasesFound++;
    21
    return columnAliases[0];
    18
    return columnAliases[0];
    Precondition Violations (3)
    Row Violation
    1Unmatched statement columnAliases=persister.getSubclassPropertyColumnAliases(propertyName,suffix); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement columnAliases=collectionPersister.getCollectionPropertyColumnAliases(propertyName,collectionSuffix); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Not all possible execution flows end in a return statement