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 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.5 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 35 |
Number of mapped statements | 9 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 3.6 |
Clone type | Type 2 |
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); | ||||
15 | columnAliases = collectionPersister.getCollectionPropertyColumnAliases(propertyName, collectionSuffix); |
| | ||||
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]; |
Row | Violation |
---|---|
1 | 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 |
2 | 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 |
3 | Not all possible execution flows end in a return statement |