if ( coll == null ) { //it might be an unwrapped collection reference! //try to find a wrapper (slowish) Iterator wrappers = IdentityMap.keyIterator(collectionEntries); while ( wrappers.hasNext() ) { PersistentCollection pc = (PersistentCollection) wrappers.next(); if ( pc.isWrapper(collection) ) { coll = pc; break; } } }
Object element = elems.next(); // worrying about proxies is perhaps a little bit of overkill here... if ( element instanceof HibernateProxy ) { LazyInitializer li = ( (HibernateProxy) element ).getHibernateLazyInitializer(); if ( !li.isUninitialized() ) element = li.getImplementation(); } if ( element == childObject ) return true;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/CollectionType.java
Method name: CollectionEntry getCollectionEntryOrNull(Object) Method name: boolean contains(Object, Object, SessionImplementor)
Number of AST nodes: 7 Number of AST nodes: 7
1
if ( coll == null ) {
2
				//it might be an unwrapped collection reference!
3
				//try to find a wrapper (slowish)
4
				Iterator wrappers = IdentityMap.keyIt
1
Object element = elems.next();
2
			// worrying about proxies is perhaps a little bit of overkill here...
3
			if ( element instanceof HibernateProxy ) {
5
erator(collectionEntries);
4
				LazyInitializer li = ( (HibernateProxy) element ).getHibernat
6
				while ( wrappers.hasNext() ) {
7
					PersistentCollection pc = (PersistentCollection) wrappers.next
5
eLazyInitializer();
8
();
6
				if ( !li.isUninitialized() ) element = li.getImplementation();
9
			
7
			}
10
		if ( pc.isWrapper(collection) ) {
8
			if ( 
11
						coll = pc;
12
						break;
13
					}
14
				}
15
			}
9
element == childObject ) return true;
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.3
Clones locationClones are in different classes
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)7.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                
    5
    LazyInitializer li = ((HibernateProxy)element).getHibernateLazyInitializer();
    Preondition Violations
    Unmatched statement LazyInitializer li=((HibernateProxy)element).getHibernateLazyInitializer(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    LazyInitializer li = ((HibernateProxy)element).getHibernateLazyInitializer();
    8
    PersistentCollection pc = (PersistentCollection)wrappers.next();
    8
    PersistentCollection pc = (PersistentCollection)wrappers.next();
    Preondition Violations
    Unmatched statement PersistentCollection pc=(PersistentCollection)wrappers.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                      
    9
    if (pc.isWrapper(collection))
    9
    if (pc.isWrapper(collection))
    6
    if (!li.isUninitialized())
    Differences
    Expression1Expression2Difference
    pc.isWrapper(collection)!li.isUninitialized()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression pc.isWrapper(collection) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression !li.isUninitialized() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    if (!li.isUninitialized())
                                                                        
    7
    element = li.getImplementation();
    Preondition Violations
    Unmatched statement element=li.getImplementation(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement element=li.getImplementation(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    7
    element = li.getImplementation();
    10
    coll = pc;
    10
    coll = pc;
    Preondition Violations
    Unmatched statement coll=pc; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                            
    11
    break;
    11
    break;
    Preondition Violations
    Unmatched break;
                        
    Precondition Violations (9)
    Row Violation
    1Unmatched statement LazyInitializer li=((HibernateProxy)element).getHibernateLazyInitializer(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement PersistentCollection pc=(PersistentCollection)wrappers.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression pc.isWrapper(collection) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression !li.isUninitialized() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement element=li.getImplementation(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement element=li.getImplementation(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    7Unmatched statement coll=pc; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched break;
    9The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero