if ( persister.isSubclassEntityName( entityEntry.getEntityName() ) ) { final Object entityEntryInstance = me.getKey(); //check if the managed object is the parent boolean found = isFoundInParent( propertyName, childEntity, persister, collectionPersister, entityEntryInstance ); if ( !found && mergeMap != null ) { //check if the detached object being merged is the parent Object unmergedInstance = mergeMap.get( entityEntryInstance ); Object unmergedChild = mergeMap.get( childEntity ); if ( unmergedInstance != null && unmergedChild != null ) { found = isFoundInParent( propertyName, unmergedChild, persister, collectionPersister, unmergedInstance ); } } if ( found ) { return entityEntry.getId(); } }
if ( persister.isSubclassEntityName( ee.getEntityName() ) ) { Object instance = me.getKey(); Object index = getIndexInParent(property, childEntity, persister, cp, instance); if (index==null && mergeMap!=null) { Object unmergedInstance = mergeMap.get(instance); Object unmergedChild = mergeMap.get(childEntity); if ( unmergedInstance!=null && unmergedChild!=null ) { index = getIndexInParent(property, unmergedChild, persister, cp, unmergedInstance); } } if (index!=null) return index; }
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/engine/StatefulPersistenceContext.java
Method name: Serializable getOwnerId(String, String, Object, Map) Method name: Object getIndexInOwner(String, String, Object, Map)
Number of AST nodes: 10 Number of AST nodes: 10
1
if ( persister.isSubclassEntityName( entityEntry.getEntityName() ) ) {
1
if ( persister.isSubclassEntityName( ee.getEntityName() ) ) {
2
				final Object entityEntryInstance = me.getKey();
2
				Object instance = me.getKey();
3
				
3
				//check if the managed object is the parent
4
				
4
				boolean found = isFoundInParent(
5
Object index = getIndexInParent(
5
						propertyName,
6
property
6
						childEntity,
7
, childEntity,
7
						persister,
8
 persister,
8
						collectionPersister,
9
						entityEntryInstance
9
 cp, instance);
10
				);
10
				
11
				if ( !found && mergeMap != null ) {
11
				if (index==null && mergeMap!=null) {
12
					//check if the detached object being merged is the parent
12
					
13
					Object unmergedInstance = mergeMap.get( entityEntryInstance );
13
Object unmergedInstance = mergeMap.get(instance);
14
					Object unmergedChild = mergeMap.get( childEntity );
14
					Object unmergedChild = mergeMap.get(childEntity);
15
					if ( unmergedInstance != null && unmergedChild != null ) {
15
					if ( unmergedInstance!=null && unmergedChild!=null ) {
16
						found = isFoundInParent(
16
						
17
								propertyName,
18
								unmergedChild,
17
index = getIndexInParent(property, unmergedChild,
19
								persister,
18
 persister,
20
								collectionPersister,
21
								unmergedInstance
19
 cp, unmergedInstance);
22
						);
20
					
23
	
21
}
24
				}
22
				}
25
				}
23
				
26
				if ( found ) {
24
				if (
27
					return entityEntry.getId();
28
				}
25
index!=null) return index;
29
			}
26
			}
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.9
Clones locationClones are declared in the same class
Number of node comparisons24
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)5.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    8
    if (persister.isSubclassEntityName(entityEntry.getEntityName()))
    8
    if (persister.isSubclassEntityName(entityEntry.getEntityName()))
    7
    if (persister.isSubclassEntityName(ee.getEntityName()))
    Differences
    Expression1Expression2Difference
    entityEntryeeVARIABLE_NAME_MISMATCH
    7
    if (persister.isSubclassEntityName(ee.getEntityName()))
                                                                  
    8
    Object instance = me.getKey();
    Preondition Violations
    Unmatched statement Object instance=me.getKey(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    Object instance = me.getKey();
                                                                                                                                                              
    9
    Object index = getIndexInParent(property, childEntity, persister, cp, instance);
    Preondition Violations
    Unmatched statement Object index=getIndexInParent(property,childEntity,persister,cp,instance); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement Object index=getIndexInParent(property,childEntity,persister,cp,instance); 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
    9
    Object index = getIndexInParent(property, childEntity, persister, cp, instance);
    9
    final Object entityEntryInstance = me.getKey();
    9
    final Object entityEntryInstance = me.getKey();
    Preondition Violations
    Unmatched statement final Object entityEntryInstance=me.getKey(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                    
    10
    boolean found = isFoundInParent(propertyName, childEntity, persister, collectionPersister, entityEntryInstance);
    10
    boolean found = isFoundInParent(propertyName, childEntity, persister, collectionPersister, entityEntryInstance);
    Preondition Violations
    Unmatched statement boolean found=isFoundInParent(propertyName,childEntity,persister,collectionPersister,entityEntryInstance); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement boolean found=isFoundInParent(propertyName,childEntity,persister,collectionPersister,entityEntryInstance); 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
                                                                                                                                                                                                                                
    11
    if (!found && mergeMap != null)
    11
    if (!found && mergeMap != null)
    10
    if (index == null && mergeMap != null)
    Differences
    Expression1Expression2Difference
    !foundindex == nullINFIX_LEFT_OPERAND_MISMATCH
    Preondition Violations
    Expression !found cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression index == null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    if (index == null && mergeMap != null)
    12
    Object unmergedInstance = mergeMap.get(entityEntryInstance);
    12
    Object unmergedInstance = mergeMap.get(entityEntryInstance);
    11
    Object unmergedInstance = mergeMap.get(instance);
    Differences
    Expression1Expression2Difference
    entityEntryInstanceinstanceVARIABLE_NAME_MISMATCH
    11
    Object unmergedInstance = mergeMap.get(instance);
    13
    Object unmergedChild = mergeMap.get(childEntity);
    12
    Object unmergedChild = mergeMap.get(childEntity);
    14
    if (unmergedInstance != null && unmergedChild != null)
    13
    if (unmergedInstance != null && unmergedChild != null)
                                                                                                                                                                      
    14
    index = getIndexInParent(property, unmergedChild, persister, cp, unmergedInstance);
    Preondition Violations
    Unmatched statement index=getIndexInParent(property,unmergedChild,persister,cp,unmergedInstance); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    index = getIndexInParent(property, unmergedChild, persister, cp, unmergedInstance);
    15
    found = isFoundInParent(propertyName, unmergedChild, persister, collectionPersister, unmergedInstance);
    15
    found = isFoundInParent(propertyName, unmergedChild, persister, collectionPersister, unmergedInstance);
    Preondition Violations
    Unmatched statement found=isFoundInParent(propertyName,unmergedChild,persister,collectionPersister,unmergedInstance); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                              
                                              
    15
    if (index != null)
                                      
    16
    return index;
    Preondition Violations
    Unmatched return index;
    16
    return index;
    16
    if (found)
                              
    17
    return entityEntry.getId();
    17
    return entityEntry.getId();
    Preondition Violations
    Unmatched statement return entityEntry.getId(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return entityEntry.getId();
                                                                  
    Precondition Violations (14)
    Row Violation
    1Unmatched statement Object instance=me.getKey(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Object index=getIndexInParent(property,childEntity,persister,cp,instance); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement Object index=getIndexInParent(property,childEntity,persister,cp,instance); 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
    4Unmatched statement final Object entityEntryInstance=me.getKey(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement boolean found=isFoundInParent(propertyName,childEntity,persister,collectionPersister,entityEntryInstance); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement boolean found=isFoundInParent(propertyName,childEntity,persister,collectionPersister,entityEntryInstance); 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
    7Expression !found cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression index == null cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Unmatched statement index=getIndexInParent(property,unmergedChild,persister,cp,unmergedInstance); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement found=isFoundInParent(propertyName,unmergedChild,persister,collectionPersister,unmergedInstance); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched return index;
    12Unmatched statement return entityEntry.getId(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13Unmatched return entityEntry.getId();
    14Clone fragment #1 returns variables unmergedInstance, unmergedChild , while Clone fragment #2 returns variables unmergedInstance, unmergedChild