ToOne toOne = (ToOne) value; String propertyRef = toOne.getReferencedPropertyName(); if ( propertyRef != null ) { mappings.addUniquePropertyReference( toOne.getReferencedEntityName(), propertyRef ); }
if ( value instanceof Collection ) { Collection coll = (Collection) value; String propertyRef = coll.getReferencedPropertyName(); // not necessarily a *unique* property reference if ( propertyRef != null ) { mappings.addPropertyReference( coll.getOwnerEntityName(), propertyRef ); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cfg/HbmBinder.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cfg/HbmBinder.java
Method name: Property createProperty(Value, String, String, Element, Mappings, java.util.Map) Method name: Property createProperty(Value, String, String, Element, Mappings, java.util.Map)
Number of AST nodes: 4 Number of AST nodes: 5
1
ToOne toOne = (ToOne
1
if ( value instanceof Collection ) {
2
) value;
2
			Collection coll = (Collection) value;
3
			String propertyRef = toOne.getReferencedPropertyName();
3
			String propertyRef = coll.getReferencedPropertyName();
4
			
4
			// not necessarily a *unique* property reference
5
if ( propertyRef != null ) {
5
			if ( propertyRef != null ) {
6
				mappings.addUniquePropertyReference( toOne.getReferencedEntityName(), propertyRef );
6
				mappings.addPropertyReference( coll.getOwnerEntityName(), propertyRef );
7
			}
7
			}
8
		}
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.2
Clones locationClones are in the same method
Number of node comparisons9
  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.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    ToOne toOne = (ToOne)value;
                                                            
                                                                                
    10
    Collection coll = (Collection)value;
    6
    String propertyRef = toOne.getReferencedPropertyName();
    6
    String propertyRef = toOne.getReferencedPropertyName();
    11
    String propertyRef = coll.getReferencedPropertyName();
    Differences
    Expression1Expression2Difference
    toOnecollVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.ToOneorg.hibernate.mapping.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.mapping.ToOne of variable toOne does not match with type org.hibernate.mapping.Collection of variable coll
    • Make classes org.hibernate.mapping.ToOne and org.hibernate.mapping.Collection extend a common superclass
    11
    String propertyRef = coll.getReferencedPropertyName();
    7
    if (propertyRef != null)
    12
    if (propertyRef != null)
    8
    mappings.addUniquePropertyReference(toOne.getReferencedEntityName(), propertyRef);
    8
    mappings.addUniquePropertyReference(toOne.getReferencedEntityName(), propertyRef);
    Preondition Violations
    Unmatched statement mappings.addUniquePropertyReference(toOne.getReferencedEntityName(),propertyRef); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                            
                                                                                                                                                      
    13
    mappings.addPropertyReference(coll.getOwnerEntityName(), propertyRef);
    Preondition Violations
    Unmatched statement mappings.addPropertyReference(coll.getOwnerEntityName(),propertyRef); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13
    mappings.addPropertyReference(coll.getOwnerEntityName(), propertyRef);
    Precondition Violations (3)
    Row Violation
    1Type org.hibernate.mapping.ToOne of variable toOne does not match with type org.hibernate.mapping.Collection of variable coll
    2Unmatched statement mappings.addUniquePropertyReference(toOne.getReferencedEntityName(),propertyRef); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement mappings.addPropertyReference(coll.getOwnerEntityName(),propertyRef); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted