List actions = ( List ) actionBatches.get( batchNumber ); if ( actions == null ) { actions = new LinkedList(); actionBatches.put( batchNumber, actions ); } actions.add( action );
MethodNode methodNode = ( MethodNode ) m; SQLFunction template = methodNode.getSQLFunction(); if ( template == null ) { // if template is null we just write the function out as it appears in the hql statement super.beginFunctionTemplate( m, i ); } else { // this function has a template -> redirect output and catch the arguments outputStack.addFirst( writer ); writer = new FunctionArguments(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/ActionQueue.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/ast/SqlGenerator.java
Method name: void addToBatch(Integer, EntityInsertAction) Method name: void beginFunctionTemplate(AST, AST)
Number of AST nodes: 5 Number of AST nodes: 6
1
List actions = ( List ) actionBatches.get( batchNumber 
1
MethodNode methodNode = ( MethodNode ) m;
2
);
2
		SQLFunction template = methodNode.getSQLFunction();
3
			if ( actions == null ) {
3
		if ( template == null ) {
4
				actions = new LinkedList();
4
			
5
				actionBatches.put( batchNumber, actions );
6
			}
7
			actions.add( action );
5
// if template is null we just write the function out as it appears in the hql statement
6
			super.beginFunctionTemplate( m, i );
7
		}
8
		else {
9
			// this function has a template -> redirect output and catch the arguments
10
			outputStack.addFirst( writer );
11
			writer = new FunctionArguments();
12
		}
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 comparisons16
  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 fragment5
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                  
    1
    MethodNode methodNode = (MethodNode)m;
    1
    List actions = (List)actionBatches.get(batchNumber);
                                                                                                              
                                                                                                            
    2
    SQLFunction template = methodNode.getSQLFunction();
    2
    if (actions == null)
    2
    if (actions == null)
    3
    if (template == null)
    Differences
    Expression1Expression2Difference
    actionstemplateVARIABLE_NAME_MISMATCH
    java.util.Listorg.hibernate.dialect.function.SQLFunctionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List of variable actions does not match with type org.hibernate.dialect.function.SQLFunction of variable template
    • Make classes java.util.List and org.hibernate.dialect.function.SQLFunction extend a common superclass
    3
    if (template == null)
    3
    actions = new LinkedList();
    3
    actions = new LinkedList();
    Preondition Violations
    Unmatched statement actions=new LinkedList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
                                                                            
    4
    super.beginFunctionTemplate(m, i);
    4
    actionBatches.put(batchNumber, actions);
                                                                                        
            
    else
                                                                    
    5
    outputStack.addFirst(writer);
                                                                        
    6
    writer = new FunctionArguments();
    5
    actions.add(action);
                                                  
    Precondition Violations (2)
    Row Violation
    1Type java.util.List of variable actions does not match with type org.hibernate.dialect.function.SQLFunction of variable template
    2Unmatched statement actions=new LinkedList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted