public TypedValue[] getTypedValues(Criteria crit, CriteriaQuery criteriaQuery) throws HibernateException { ArrayList typedValues = new ArrayList(); Iterator iter = criteria.iterator(); while ( iter.hasNext() ) { TypedValue[] subvalues = ( (Criterion) iter.next() ).getTypedValues(crit, criteriaQuery); for ( int i=0; i<subvalues.length; i++ ) { typedValues.add( subvalues[i] ); } } return (TypedValue[]) typedValues.toArray( new TypedValue[ typedValues.size() ] ); }
public PersistentBag(SessionImplementor session, Collection coll) { super(session); if (coll instanceof List) { bag = (List) coll; } else { bag = new ArrayList(); Iterator iter = coll.iterator(); while ( iter.hasNext() ) { bag.add( iter.next() ); } } setInitialized(); setDirectlyAccessible(true); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/criterion/Junction.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/collection/PersistentBag.java
Method name: TypedValue[] getTypedValues(Criteria, CriteriaQuery) Method name: void PersistentBag(SessionImplementor, Collection)
Number of AST nodes: 2 Number of AST nodes: 2
1
public TypedValue[] getTypedValues(Criteria crit, CriteriaQuery criteriaQuery)
1
public PersistentBag(SessionImplementor session, Collection coll) {
2
	throws HibernateException {
2
		super(session);
3
		ArrayList typedValues = new ArrayList();
3
		if (coll instanceof List) {
4
		Iterator iter = criteria.iterator();
4
			bag = (List) coll;
5
		while ( iter.hasNext() ) {
5
		}
6
			TypedValue[] subvalues = ( (Criterion) iter.next() ).getTypedValues(crit, criteriaQuery);
6
		else {
7
			for ( int i=0; i<subvalues.length; i++ ) {
7
			bag = new ArrayList();
8
				typedValues.add( subvalues[i] );
8
			Iterator iter = coll.iterator();
9
			}
9
			while ( iter.hasNext() ) {
10
		}
10
				bag.add( iter.next() );
11
		return (TypedValue[]) typedValues.toArray( new TypedValue[ typedValues.size() ] );
11
			}
12
	}
12
		}
13
		setInitialized();
14
		setDirectlyAccessible(true);
15
	}
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.500
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    for (int i = 0; i < subvalues.length; i++)
    5
    for (int i = 0; i < subvalues.length; i++)
    6
    while (iter.hasNext())
    Differences
    Expression1Expression2Difference
    i < subvalues.lengthiter.hasNext()TYPE_COMPATIBLE_REPLACEMENT
    org.hibernate.engine.TypedValue[]java.util.CollectionVARIABLE_TYPE_MISMATCH
    org.hibernate.engine.TypedValue[]java.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.engine.TypedValue[] of variable subvalues does not match with type java.util.Collection of variable coll
    • Make classes org.hibernate.engine.TypedValue[] and java.util.Collection extend a common superclass
    Type org.hibernate.engine.TypedValue[] of variable subvalues does not match with type java.util.Collection of variable coll
    • Make classes org.hibernate.engine.TypedValue[] and java.util.Collection extend a common superclass
    6
    while (iter.hasNext())
    6
    typedValues.add(subvalues[i]);
    6
    typedValues.add(subvalues[i]);
    Preondition Violations
    Unmatched statement typedValues.add(subvalues[i]); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                      
                                                    
    7
    bag.add(iter.next());
    Precondition Violations (4)
    Row Violation
    1Type org.hibernate.engine.TypedValue[] of variable subvalues does not match with type java.util.Collection of variable coll
    2Type org.hibernate.engine.TypedValue[] of variable subvalues does not match with type java.util.Collection of variable coll
    3Unmatched statement typedValues.add(subvalues[i]); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Clone fragment #1 returns variables i , while Clone fragment #2 returns variables