if ( criteria instanceof CriteriaImpl ) { return ( ( CriteriaImpl ) criteria ).getSession(); } else if ( criteria instanceof CriteriaImpl.Subcriteria ) { return deriveRootSession( ( ( CriteriaImpl.Subcriteria ) criteria ).getParent() ); } else { // could happen for custom Criteria impls. Not likely, but... // for long term solution, see HHH-3514 return null; }
if ( value instanceof BigInteger ) { return ( ( BigInteger ) value ).doubleValue(); } else if ( value instanceof BigDecimal ) { return ( ( BigDecimal ) value ).doubleValue(); } else { return Double.valueOf( value.toString() ).doubleValue(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java
Method name: SessionImplementor deriveRootSession(Criteria) Method name: double extractDoubleValue(Object)
Number of AST nodes: 5 Number of AST nodes: 5
1
if ( criteria instanceof CriteriaImpl ) {
1
if ( value instanceof BigInteger ) {
2
			return ( ( CriteriaImpl ) criteria ).getSession();
2
			return ( ( BigInteger ) value ).doubleValue();
3
		}
3
		}
4
		else if ( criteria instanceof CriteriaImpl.Subcriteria ) {
4
		else if ( value instanceof 
5
			return deriveRootSession( ( ( CriteriaImpl.Subcriteria ) criteria ).getParent() 
5
BigDecimal ) {
6
);
6
			return ( ( BigDecimal ) value ).doubleValue();
7
		}
7
		}
8
		else {
8
		else {
9
			// could happen for custom Criteria impls.  Not likely, but...
9
			
10
			// 		for long term solution, see HHH-3514
11
			return null;
10
return Double.valueOf( value.toString() ).doubleValue();
12
		}
11
		}
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.5
Clones locationClones are in different classes
Number of node comparisons20
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)1.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                            
    2
    return ((BigInteger)value).doubleValue();
    Preondition Violations
    Unmatched statement return ((BigInteger)value).doubleValue(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return ((BigInteger)value).doubleValue();
    2
    return ((BigInteger)value).doubleValue();
    2
    return ((CriteriaImpl)criteria).getSession();
    2
    return ((CriteriaImpl)criteria).getSession();
    Preondition Violations
    Unmatched statement return ((CriteriaImpl)criteria).getSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return ((CriteriaImpl)criteria).getSession();
                                                                                                    
                                                                        
    3
    else if (value instanceof BigDecimal)
    Preondition Violations
    Unmatched statement if(value instanceof BigDecimal) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    else if (value instanceof BigDecimal)
                                                                                            
    4
    return ((BigDecimal)value).doubleValue();
    Preondition Violations
    Unmatched statement return ((BigDecimal)value).doubleValue(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return ((BigDecimal)value).doubleValue();
    4
    return ((BigDecimal)value).doubleValue();
            
    else
                                                                                                                      
    5
    return Double.valueOf(value.toString()).doubleValue();
    Preondition Violations
    Unmatched statement return Double.valueOf(value.toString()).doubleValue(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return Double.valueOf(value.toString()).doubleValue();
    5
    return Double.valueOf(value.toString()).doubleValue();
    3
    else if (criteria instanceof CriteriaImpl.Subcriteria)
    3
    else if (criteria instanceof CriteriaImpl.Subcriteria)
    Preondition Violations
    Unmatched statement if(criteria instanceof CriteriaImpl.Subcriteria) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                          
    4
    return deriveRootSession(((CriteriaImpl.Subcriteria)criteria).getParent());
    4
    return deriveRootSession(((CriteriaImpl.Subcriteria)criteria).getParent());
    Preondition Violations
    Unmatched statement return deriveRootSession(((CriteriaImpl.Subcriteria)criteria).getParent()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return deriveRootSession(((CriteriaImpl.Subcriteria)criteria).getParent());
                                                                                                                                                                
    else
            
    5
    return null;
    5
    return null;
    Preondition Violations
    Unmatched return null;
                                  
    Precondition Violations (14)
    Row Violation
    1Unmatched statement return ((BigInteger)value).doubleValue(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched return ((BigInteger)value).doubleValue();
    3Unmatched statement return ((CriteriaImpl)criteria).getSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched return ((CriteriaImpl)criteria).getSession();
    5Unmatched statement if(value instanceof BigDecimal) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement return ((BigDecimal)value).doubleValue(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched return ((BigDecimal)value).doubleValue();
    8Unmatched statement return Double.valueOf(value.toString()).doubleValue(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9Unmatched return Double.valueOf(value.toString()).doubleValue();
    10Unmatched statement if(criteria instanceof CriteriaImpl.Subcriteria) cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11Unmatched statement return deriveRootSession(((CriteriaImpl.Subcriteria)criteria).getParent()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Unmatched return deriveRootSession(((CriteriaImpl.Subcriteria)criteria).getParent());
    13Unmatched return null;
    14The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero