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 resolveProperties(String, String)
|
Method name: String resolveCollectionProperties(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 = persister.getSubclassPropertyColumnAliases( propertyName, suffix );↵ | 5 | columnAliases = collectionPersister.getCollectionPropertyColumnAliases( propertyName, collectionSuffix );↵ | |
6 | }↵ | 6 | }↵ | |
7 | ↵ | |||
7 | if ( columnAliases == null || columnAliases.length == 0 ) {↵ | 8 | if ( columnAliases == null || columnAliases.length == 0 ) {↵ | |
8 | throw new QueryException(↵ | 9 | throw new QueryException(↵ | |
9 | "No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",↵ | 10 | "No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",↵ | |
10 | originalQueryString↵ | 11 | originalQueryString↵ | |
11 | );↵ | 12 | );↵ | |
12 | }↵ | 13 | }↵ | |
13 | if ( columnAliases.length != 1 ) {↵ | 14 | if ( columnAliases.length != 1 ) {↵ | |
14 | // TODO: better error message since we actually support composites if names are explicitly listed.↵ | 15 | // TODO: better error message since we actually support composites if names are explicitly listed.↵ | |
15 | throw new QueryException(↵ | 16 | throw new QueryException(↵ | |
16 | "SQL queries only support properties mapped to a single column - property [" + ↵ | 17 | "SQL queries only support properties mapped to a single column - property [" +↵ | |
17 | propertyName + "] is mapped to " + columnAliases.length + " columns.",↵ | 18 | propertyName + "] is mapped to " + columnAliases.length + " columns.",↵ | |
18 | originalQueryString↵ | 19 | originalQueryString↵ | |
19 | );↵ | 20 | );↵ | |
20 | } ↵ | 21 | }↵ | |
21 | aliasesFound++;↵ | 22 | aliasesFound++;↵ | |
22 | return columnAliases[0]; | 23 |
| |
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) | 0.9 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 38 |
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) | 1.7 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
9 | String[] columnAliases; | 12 | String[] columnAliases; | ||||
10 | columnAliases = (String[])fieldResults.get(propertyName); | 13 | columnAliases = (String[])fieldResults.get(propertyName); | ||||
11 | if (columnAliases == null) | 14 | if (columnAliases == null) | ||||
12 | columnAliases = persister.getSubclassPropertyColumnAliases(propertyName, suffix); |
| | ||||
|
| 15 | columnAliases = collectionPersister.getCollectionPropertyColumnAliases(propertyName, collectionSuffix); | ||||
13 | if (columnAliases == null || columnAliases.length == 0) | 16 | if (columnAliases == null || columnAliases.length == 0) | ||||
14 | throw new QueryException("No column name found for property [" + propertyName + "] for alias [" + aliasName + "]", originalQueryString); | 17 | throw new QueryException("No column name found for property [" + propertyName + "] for alias [" + aliasName + "]", originalQueryString); | ||||
15 | if (columnAliases.length != 1) | 18 | if (columnAliases.length != 1) | ||||
16 | throw new QueryException("SQL queries only support properties mapped to a single column - property [" + propertyName + "] is mapped to " + columnAliases.length + " columns.", originalQueryString); | 19 | throw new QueryException("SQL queries only support properties mapped to a single column - property [" + propertyName + "] is mapped to " + columnAliases.length + " columns.", originalQueryString); | ||||
17 | aliasesFound++; | 20 | aliasesFound++; | ||||
18 | return columnAliases[0]; | 21 | 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 |