String entityName = ( (OneToMany) collection.getElement() ).getReferencedEntityName(); PersistentClass referenced = mappings.getClass( entityName ); Backref prop = new Backref(); prop.setName( '_' + collection.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "Backref" ); prop.setUpdateable( false ); prop.setSelectable( false ); prop.setCollectionRole( collection.getRole() ); prop.setEntityName( collection.getOwner().getEntityName() ); prop.setValue( collection.getKey() ); referenced.addProperty( prop );
if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) { String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName(); PersistentClass referenced = mappings.getClass( entityName ); IndexBackref ib = new IndexBackref(); ib.setName( '_' + list.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" ); ib.setUpdateable( false ); ib.setSelectable( false ); ib.setCollectionRole( list.getRole() ); ib.setEntityName( list.getOwner().getEntityName() ); ib.setValue( list.getIndex() ); // ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next() // ).setNullable(false); referenced.addProperty( ib ); }
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: void bindCollectionSecondPass(Element, Collection, java.util.Map, Mappings, java.util.Map) Method name: void bindListSecondPass(Element, List, java.util.Map, Mappings, java.util.Map)
Number of AST nodes: 10 Number of AST nodes: 11
1
if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) {
1
String entityName = ( (OneToMany) collection.getElement() ).getReferencedEntityName();
2
			String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName();
2
			PersistentClass referenced = mappings.getClass( entityName );
3
			PersistentClass referenced = mappings.getClass( entityName );
3
			Backref prop = new Backref();
4
			IndexBackref ib = new IndexBackref();
4
			prop.setName( '_' + collection.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "Backref" );
5
			ib.setName( '_' + list.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" );
5
			prop.setUpdateable( false );
6
			ib.setUpdateable( false );
6
			prop.setSelectable( false );
7
			ib.setSelectable( false );
7
			prop.setCollectionRole( collection.getRole() );
8
			ib.setCollectionRole( list.getRole() );
8
			prop.setEntityName( collection.getOwner().getEntityName() );
9
			ib.setEntityName( list.getOwner().getEntityName() );
9
			prop.setValue( collection.getKey() 
10
			ib.setValue( list.getIndex() );
11
			// ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next()
10
);
12
			// ).setNullable(false);
11
			referenced.addProperty( prop );
13
			referenced.addProperty( ib );
14
		}
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.0
Clones locationClones are declared in the same class
Number of node comparisons72
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    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
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    55
    String entityName = ((OneToMany)collection.getElement()).getReferencedEntityName();
    55
    String entityName = ((OneToMany)collection.getElement()).getReferencedEntityName();
    14
    String entityName = ((OneToMany)list.getElement()).getReferencedEntityName();
    Differences
    Expression1Expression2Difference
    collectionlistVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Collectionorg.hibernate.mapping.ListSUBCLASS_TYPE_MISMATCH
    14
    String entityName = ((OneToMany)list.getElement()).getReferencedEntityName();
    56
    PersistentClass referenced = mappings.getClass(entityName);
    15
    PersistentClass referenced = mappings.getClass(entityName);
    57
    Backref prop = new Backref();
    57
    Backref prop = new Backref();
    16
    IndexBackref ib = new IndexBackref();
    Differences
    Expression1Expression2Difference
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    propibVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    16
    IndexBackref ib = new IndexBackref();
    58
    prop.setName('_' + collection.getOwnerEntityName() + "." + node.attributeValue("name") + "Backref");
    58
    prop.setName('_' + collection.getOwnerEntityName() + "." + node.attributeValue("name") + "Backref");
    21
    ib.setEntityName(list.getOwner().getEntityName());
    Differences
    Expression1Expression2Difference
    setNamesetEntityNameMETHOD_INVOCATION_NAME_MISMATCH
    '_' + collection.getOwnerEntityName() + "."+ node.attributeValue("name")+ "Backref"list.getOwner().getEntityName()TYPE_COMPATIBLE_REPLACEMENT
    propibVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression prop.setName('_' + collection.getOwnerEntityName() + "."+ node.attributeValue("name")+ "Backref") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ib.setEntityName(list.getOwner().getEntityName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression prop.setName('_' + collection.getOwnerEntityName() + "."+ node.attributeValue("name")+ "Backref") is a void method call, and thus it cannot be parameterized
    Expression ib.setEntityName(list.getOwner().getEntityName()) is a void method call, and thus it cannot be parameterized
    21
    ib.setEntityName(list.getOwner().getEntityName());
    59
    prop.setUpdateable(false);
    59
    prop.setUpdateable(false);
    18
    ib.setUpdateable(false);
    Differences
    Expression1Expression2Difference
    propibVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    18
    ib.setUpdateable(false);
    60
    prop.setSelectable(false);
    60
    prop.setSelectable(false);
    19
    ib.setSelectable(false);
    Differences
    Expression1Expression2Difference
    propibVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    19
    ib.setSelectable(false);
    61
    prop.setCollectionRole(collection.getRole());
    61
    prop.setCollectionRole(collection.getRole());
    20
    ib.setCollectionRole(list.getRole());
    Differences
    Expression1Expression2Difference
    collectionlistVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Collectionorg.hibernate.mapping.ListSUBCLASS_TYPE_MISMATCH
    propibVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression prop cannot be unified with expression ib , because common superclass org.hibernate.mapping.Property does not declare member(s) public void setCollectionRole(java.lang.String)
    20
    ib.setCollectionRole(list.getRole());
    62
    prop.setEntityName(collection.getOwner().getEntityName());
    62
    prop.setEntityName(collection.getOwner().getEntityName());
    17
    ib.setName('_' + list.getOwnerEntityName() + "." + node.attributeValue("name") + "IndexBackref");
    Differences
    Expression1Expression2Difference
    setEntityNamesetNameMETHOD_INVOCATION_NAME_MISMATCH
    collection.getOwner().getEntityName()'_' + list.getOwnerEntityName() + "."+ node.attributeValue("name")+ "IndexBackref"TYPE_COMPATIBLE_REPLACEMENT
    propibVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression prop.setEntityName(collection.getOwner().getEntityName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ib.setName('_' + list.getOwnerEntityName() + "."+ node.attributeValue("name")+ "IndexBackref") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression prop.setEntityName(collection.getOwner().getEntityName()) is a void method call, and thus it cannot be parameterized
    Expression ib.setName('_' + list.getOwnerEntityName() + "."+ node.attributeValue("name")+ "IndexBackref") is a void method call, and thus it cannot be parameterized
    17
    ib.setName('_' + list.getOwnerEntityName() + "." + node.attributeValue("name") + "IndexBackref");
                                                                      
    22
    ib.setValue(list.getIndex());
    63
    prop.setValue(collection.getKey());
                                                                                  
    64
    referenced.addProperty(prop);
    64
    referenced.addProperty(prop);
    23
    referenced.addProperty(ib);
    Differences
    Expression1Expression2Difference
    propibVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Backreforg.hibernate.mapping.IndexBackrefSUBCLASS_TYPE_MISMATCH
    23
    referenced.addProperty(ib);
    Precondition Violations (10)
    Row Violation
    1Expression prop.setName('_' + collection.getOwnerEntityName() + "."+ node.attributeValue("name")+ "Backref") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression ib.setEntityName(list.getOwner().getEntityName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression prop.setName('_' + collection.getOwnerEntityName() + "."+ node.attributeValue("name")+ "Backref") is a void method call, and thus it cannot be parameterized
    4Expression ib.setEntityName(list.getOwner().getEntityName()) is a void method call, and thus it cannot be parameterized
    5Expression prop cannot be unified with expression ib , because common superclass org.hibernate.mapping.Property does not declare member(s) public void setCollectionRole(java.lang.String)
    6Expression prop.setEntityName(collection.getOwner().getEntityName()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression ib.setName('_' + list.getOwnerEntityName() + "."+ node.attributeValue("name")+ "IndexBackref") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression prop.setEntityName(collection.getOwner().getEntityName()) is a void method call, and thus it cannot be parameterized
    9Expression ib.setName('_' + list.getOwnerEntityName() + "."+ node.attributeValue("name")+ "IndexBackref") is a void method call, and thus it cannot be parameterized
    10Clone fragment #1 returns variable prop with type org.hibernate.mapping.Backref , while Clone fragment #2 returns variable ib with type org.hibernate.mapping.IndexBackref