SQLFunction f = findSQLFunction( functionName ); if ( f == null ) { throw new QueryException( "Unable to find SQL function: " + functionName ); } return f;
Session current = existingSession( factory ); if ( current == null ) { throw new HibernateException( "No session currently bound to execution context" ); } return current;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/ast/util/SessionFactoryHelper.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/context/ManagedSessionContext.java
Method name: SQLFunction requireSQLFunction(String) Method name: Session currentSession()
Number of AST nodes: 4 Number of AST nodes: 4
1
SQLFunction f = findSQLFunction( functionName );
1
Session current = existingSession( factory );
2
		if ( f == null ) {
2
		if ( current == null ) {
3
			throw new QueryException( "Unable to find SQL function: " + functionName );
3
			throw new HibernateException( "No session currently bound to execution context" );
4
		}
4
		}
5
		return f;
5
		return current;
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.1
Clones locationClones are in different classes
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                            
    1
    Session current = existingSession(factory);
    1
    SQLFunction f = findSQLFunction(functionName);
                                                                                                  
    2
    if (f == null)
    2
    if (f == null)
    2
    if (current == null)
    Differences
    Expression1Expression2Difference
    fcurrentVARIABLE_NAME_MISMATCH
    org.hibernate.dialect.function.SQLFunctionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.dialect.function.SQLFunction of variable f does not match with type org.hibernate.classic.Session of variable current
    • Make classes org.hibernate.dialect.function.SQLFunction and org.hibernate.classic.Session extend a common superclass
    2
    if (current == null)
    3
    throw new QueryException("Unable to find SQL function: " + functionName);
    3
    throw new QueryException("Unable to find SQL function: " + functionName);
    3
    throw new HibernateException("No session currently bound to execution context");
    Differences
    Expression1Expression2Difference
    org.hibernate.QueryExceptionorg.hibernate.HibernateExceptionSUBCLASS_TYPE_MISMATCH
    "Unable to find SQL function: " + functionName"No session currently bound to execution context"TYPE_COMPATIBLE_REPLACEMENT
    3
    throw new HibernateException("No session currently bound to execution context");
                                        
    4
    return current;
    Preondition Violations
    Unmatched return current;
    4
    return current;
    4
    return f;
    4
    return f;
    Preondition Violations
    Unmatched return f;
                            
    Precondition Violations (3)
    Row Violation
    1Type org.hibernate.dialect.function.SQLFunction of variable f does not match with type org.hibernate.classic.Session of variable current
    2Unmatched return current;
    3Unmatched return f;