ParentWithCollection dummyParent = createParent( "dummyParent" ); dummyParent.newChildren( createCollection() ); Child dummyChild = dummyParent.addChild( "dummyChild" ); Session s = openSession(); Transaction tx = s.beginTransaction(); List children = s.createCriteria( dummyChild.getClass() ).list(); List parents = s.createCriteria( dummyParent.getClass() ).list(); for ( Iterator it = parents.iterator(); it.hasNext(); ) { ParentWithCollection parent = ( ParentWithCollection ) it.next(); parent.clearChildren(); s.delete( parent ); } for ( Iterator it = children.iterator(); it.hasNext(); ) { s.delete( it.next() ); } tx.commit(); s.close();
ParentWithCollection dummyParent = createParent( "dummyParent" ); dummyParent.setChildren( createCollection() ); Child dummyChild = dummyParent.addChild( "dummyChild" ); Session s = openSession(); Transaction tx = s.beginTransaction(); List children = s.createCriteria( dummyChild.getClass() ).list(); List parents = s.createCriteria( dummyParent.getClass() ).list(); for ( Iterator it = parents.iterator(); it.hasNext(); ) { ParentWithCollection parent = ( ParentWithCollection ) it.next(); parent.clearChildren(); s.delete( parent ); } for ( Iterator it = children.iterator(); it.hasNext(); ) { s.delete( it.next() ); } tx.commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/event/collection/AbstractCollectionEventTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/event/collection/BrokenCollectionEventTest.java
Method name: void cleanupTest() Method name: void cleanupTest()
Number of AST nodes: 15 Number of AST nodes: 15
1
ParentWithCollection dummyParent = createParent( "dummyParent" );
1
ParentWithCollection dummyParent = createParent( "dummyParent" );
2
		dummyParent.newChildren( createCollection() );
2
		dummyParent.setChildren( createCollection() );
3
		Child dummyChild = dummyParent.addChild( "dummyChild" );
3
		Child dummyChild = dummyParent.addChild( "dummyChild" );
4
		Session s = openSession();
4
		Session s = openSession();
5
		Transaction tx = s.beginTransaction();
5
		Transaction tx = s.beginTransaction();
6
		List children = s.createCriteria( dummyChild.getClass() ).list();
6
		List children = s.createCriteria( dummyChild.getClass() ).list();
7
		List parents = s.createCriteria( dummyParent.getClass() ).list();
7
		List parents = s.createCriteria( dummyParent.getClass() ).list();
8
		for ( Iterator it = parents.iterator(); it.hasNext(); ) {
8
		for ( Iterator it = parents.iterator(); it.hasNext(); ) {
9
			ParentWithCollection parent = ( ParentWithCollection ) it.next();
9
			ParentWithCollection parent = ( ParentWithCollection ) it.next();
10
			parent.clearChildren();
10
			parent.clearChildren();
11
			s.delete( parent );
11
			s.delete( parent );
12
		}
12
		}
13
		for ( Iterator it = children.iterator(); it.hasNext(); ) {
13
		for ( Iterator it = children.iterator(); it.hasNext(); ) {
14
			s.delete( it.next() );
14
			s.delete( it.next() );
15
		}
15
		}
16
		tx.commit();
16
		tx.commit();
17
		s.close();
17
		s.close();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.5
Clones locationClones are in different classes having the same super class
Number of node comparisons66
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)25.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    ParentWithCollection dummyParent = createParent("dummyParent");
    1
    ParentWithCollection dummyParent = createParent("dummyParent");
    2
    dummyParent.newChildren(createCollection());
    2
    dummyParent.newChildren(createCollection());
    2
    dummyParent.setChildren(createCollection());
    Differences
    Expression1Expression2Difference
    newChildrensetChildrenMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression dummyParent.newChildren(createCollection()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression dummyParent.setChildren(createCollection()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression dummyParent.newChildren(createCollection()) is a void method call, and thus it cannot be parameterized
    Expression dummyParent.setChildren(createCollection()) is a void method call, and thus it cannot be parameterized
    2
    dummyParent.setChildren(createCollection());
    3
    Child dummyChild = dummyParent.addChild("dummyChild");
    3
    Child dummyChild = dummyParent.addChild("dummyChild");
    4
    Session s = openSession();
    4
    Session s = openSession();
    5
    Transaction tx = s.beginTransaction();
    5
    Transaction tx = s.beginTransaction();
    6
    List children = s.createCriteria(dummyChild.getClass()).list();
    6
    List children = s.createCriteria(dummyChild.getClass()).list();
    7
    List parents = s.createCriteria(dummyParent.getClass()).list();
    7
    List parents = s.createCriteria(dummyParent.getClass()).list();
    8
    for (Iterator it = parents.iterator(); it.hasNext(); )
    8
    for (Iterator it = parents.iterator(); it.hasNext(); )
    9
    ParentWithCollection parent = (ParentWithCollection)it.next();
    9
    ParentWithCollection parent = (ParentWithCollection)it.next();
    10
    parent.clearChildren();
    10
    parent.clearChildren();
    11
    s.delete(parent);
    11
    s.delete(parent);
    12
    for (Iterator it = children.iterator(); it.hasNext(); )
    12
    for (Iterator it = children.iterator(); it.hasNext(); )
    13
    s.delete(it.next());
    13
    s.delete(it.next());
    14
    tx.commit();
    14
    tx.commit();
    15
    s.close();
    15
    s.close();
    Precondition Violations (4)
    Row Violation
    1Expression dummyParent.newChildren(createCollection()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression dummyParent.setChildren(createCollection()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression dummyParent.newChildren(createCollection()) is a void method call, and thus it cannot be parameterized
    4Expression dummyParent.setChildren(createCollection()) is a void method call, and thus it cannot be parameterized