BagOwner parent = new BagOwner( "root" ); BagOwner child = new BagOwner( "c1" ); parent.getChildren().add( child ); child.setParent( parent ); BagOwner otherChild = new BagOwner( "c2" ); Session session = openSession(); session.beginTransaction(); session.save( parent ); session.flush(); // at this point, the list on parent has now been replaced with a PersistentBag... PersistentBag children = ( PersistentBag ) parent.getChildren(); assertFalse( children.remove( otherChild ) ); assertFalse( children.isDirty() ); ArrayList otherCollection = new ArrayList(); otherCollection.add( child ); assertFalse( children.retainAll( otherCollection ) ); assertFalse( children.isDirty() ); otherCollection = new ArrayList(); otherCollection.add( otherChild ); assertFalse( children.removeAll( otherCollection ) ); assertFalse( children.isDirty() ); children.clear(); session.delete( child ); assertTrue( children.isDirty() ); session.flush(); children.clear(); assertFalse( children.isDirty() ); session.delete( parent ); session.getTransaction().commit(); session.close();
ListOwner parent = new ListOwner( "root" ); ListOwner child = new ListOwner( "c1" ); parent.getChildren().add( child ); child.setParent( parent ); ListOwner otherChild = new ListOwner( "c2" ); Session session = openSession(); session.beginTransaction(); session.save( parent ); session.flush(); // at this point, the list on parent has now been replaced with a PersistentList... PersistentList children = ( PersistentList ) parent.getChildren(); assertFalse( children.remove( otherChild ) ); assertFalse( children.isDirty() ); ArrayList otherCollection = new ArrayList(); otherCollection.add( child ); assertFalse( children.retainAll( otherCollection ) ); assertFalse( children.isDirty() ); otherCollection = new ArrayList(); otherCollection.add( otherChild ); assertFalse( children.removeAll( otherCollection ) ); assertFalse( children.isDirty() ); children.clear(); session.delete( child ); assertTrue( children.isDirty() ); session.flush(); children.clear(); assertFalse( children.isDirty() ); session.delete( parent ); session.getTransaction().commit(); session.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/bag/PersistentBagTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/list/PersistentListTest.java
Method name: void testWriteMethodDirtying() Method name: void testWriteMethodDirtying()
Number of AST nodes: 29 Number of AST nodes: 29
1
BagOwner parent = new BagOwner( "root" );
1
ListOwner parent = new ListOwner( "root" );
2
		BagOwner child = new BagOwner( "c1" );
2
		ListOwner child = new ListOwner( "c1" );
3
		parent.getChildren().add( child );
3
		parent.getChildren().add( child );
4
		child.setParent( parent );
4
		child.setParent( parent );
5
		BagOwner otherChild = new BagOwner( "c2" );
5
		ListOwner otherChild = new ListOwner( "c2" );
6
		Session session = openSession();
6
		Session session = openSession();
7
		session.beginTransaction();
7
		session.beginTransaction();
8
		session.save( parent );
8
		session.save( parent );
9
		session.flush();
9
		session.flush();
10
		// at this point, the list on parent has now been replaced with a PersistentBag...
10
		// at this point, the list on parent has now been replaced with a PersistentList...
11
		PersistentBag children = ( PersistentBag ) parent.getChildren();
11
		PersistentList children = ( PersistentList ) parent.getChildren();
12
		assertFalse( children.remove( otherChild ) );
12
		assertFalse( children.remove( otherChild ) );
13
		assertFalse( children.isDirty() );
13
		assertFalse( children.isDirty() );
14
		ArrayList otherCollection = new ArrayList();
14
		ArrayList otherCollection = new ArrayList();
15
		otherCollection.add( child );
15
		otherCollection.add( child );
16
		assertFalse( children.retainAll( otherCollection ) );
16
		assertFalse( children.retainAll( otherCollection ) );
17
		assertFalse( children.isDirty() );
17
		assertFalse( children.isDirty() );
18
		otherCollection = new ArrayList();
18
		otherCollection = new ArrayList();
19
		otherCollection.add( otherChild );
19
		otherCollection.add( otherChild );
20
		assertFalse( children.removeAll( otherCollection ) );
20
		assertFalse( children.removeAll( otherCollection ) );
21
		assertFalse( children.isDirty() );
21
		assertFalse( children.isDirty() );
22
		children.clear();
22
		children.clear();
23
		session.delete( child );
23
		session.delete( child );
24
		assertTrue( children.isDirty() );
24
		assertTrue( children.isDirty() );
25
		session.flush();
25
		session.flush();
26
		children.clear();
26
		children.clear();
27
		assertFalse( children.isDirty() );
27
		assertFalse( children.isDirty() );
28
		session.delete( parent );
28
		session.delete( parent );
29
		session.getTransaction().commit();
29
		session.getTransaction().commit();
30
		session.close();
30
		session.close();
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 in different classes having the same super class
Number of node comparisons366
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements26
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                        
    1
    ListOwner parent = new ListOwner("root");
    Preondition Violations
    Unmatched statement ListOwner parent=new ListOwner("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    ListOwner parent = new ListOwner("root");
    1
    BagOwner parent = new BagOwner("root");
    1
    BagOwner parent = new BagOwner("root");
    Preondition Violations
    Unmatched statement BagOwner parent=new BagOwner("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                    
                                                                                  
    2
    ListOwner child = new ListOwner("c1");
    Preondition Violations
    Unmatched statement ListOwner child=new ListOwner("c1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    ListOwner child = new ListOwner("c1");
    2
    BagOwner child = new BagOwner("c1");
    2
    BagOwner child = new BagOwner("c1");
    Preondition Violations
    Unmatched statement BagOwner child=new BagOwner("c1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                              
    3
    parent.getChildren().add(child);
    3
    parent.getChildren().add(child);
    3
    parent.getChildren().add(child);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.bag.BagOwner of variable child does not match with type org.hibernate.test.collection.list.ListOwner of variable child
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    3
    parent.getChildren().add(child);
    4
    child.setParent(parent);
    4
    child.setParent(parent);
    4
    child.setParent(parent);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    Type org.hibernate.test.collection.bag.BagOwner of variable child does not match with type org.hibernate.test.collection.list.ListOwner of variable child
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    4
    child.setParent(parent);
                                                                                            
    5
    ListOwner otherChild = new ListOwner("c2");
    Preondition Violations
    Unmatched statement ListOwner otherChild=new ListOwner("c2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    ListOwner otherChild = new ListOwner("c2");
    5
    BagOwner otherChild = new BagOwner("c2");
    5
    BagOwner otherChild = new BagOwner("c2");
    Preondition Violations
    Unmatched statement BagOwner otherChild=new BagOwner("c2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                        
    6
    Session session = openSession();
    6
    Session session = openSession();
    7
    session.beginTransaction();
    7
    session.beginTransaction();
    8
    session.save(parent);
    8
    session.save(parent);
    8
    session.save(parent);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    8
    session.save(parent);
    9
    session.flush();
    9
    session.flush();
    10
    PersistentBag children = (PersistentBag)parent.getChildren();
    10
    PersistentBag children = (PersistentBag)parent.getChildren();
    10
    PersistentList children = (PersistentList)parent.getChildren();
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression (PersistentBag)parent.getChildren() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (PersistentList)parent.getChildren() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    10
    PersistentList children = (PersistentList)parent.getChildren();
    11
    assertFalse(children.remove(otherChild));
    11
    assertFalse(children.remove(otherChild));
    11
    assertFalse(children.remove(otherChild));
    Differences
    Expression1Expression2Difference
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.bag.BagOwner of variable otherChild does not match with type org.hibernate.test.collection.list.ListOwner of variable otherChild
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public boolean remove(java.lang.Object)
    11
    assertFalse(children.remove(otherChild));
    12
    assertFalse(children.isDirty());
    12
    assertFalse(children.isDirty());
    12
    assertFalse(children.isDirty());
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    12
    assertFalse(children.isDirty());
    13
    ArrayList otherCollection = new ArrayList();
    13
    ArrayList otherCollection = new ArrayList();
    14
    otherCollection.add(child);
    14
    otherCollection.add(child);
    14
    otherCollection.add(child);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.bag.BagOwner of variable child does not match with type org.hibernate.test.collection.list.ListOwner of variable child
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    14
    otherCollection.add(child);
    15
    assertFalse(children.retainAll(otherCollection));
    15
    assertFalse(children.retainAll(otherCollection));
    15
    assertFalse(children.retainAll(otherCollection));
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public boolean retainAll(Collection#RAW)
    15
    assertFalse(children.retainAll(otherCollection));
    16
    assertFalse(children.isDirty());
    16
    assertFalse(children.isDirty());
    16
    assertFalse(children.isDirty());
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    16
    assertFalse(children.isDirty());
    17
    otherCollection = new ArrayList();
    17
    otherCollection = new ArrayList();
    18
    otherCollection.add(otherChild);
    18
    otherCollection.add(otherChild);
    18
    otherCollection.add(otherChild);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.bag.BagOwner of variable otherChild does not match with type org.hibernate.test.collection.list.ListOwner of variable otherChild
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    18
    otherCollection.add(otherChild);
    19
    assertFalse(children.removeAll(otherCollection));
    19
    assertFalse(children.removeAll(otherCollection));
    19
    assertFalse(children.removeAll(otherCollection));
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public boolean removeAll(Collection#RAW)
    19
    assertFalse(children.removeAll(otherCollection));
    20
    assertFalse(children.isDirty());
    20
    assertFalse(children.isDirty());
    20
    assertFalse(children.isDirty());
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    20
    assertFalse(children.isDirty());
    21
    children.clear();
    21
    children.clear();
    21
    children.clear();
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public void clear()
    21
    children.clear();
    22
    session.delete(child);
    22
    session.delete(child);
    22
    session.delete(child);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.bag.BagOwner of variable child does not match with type org.hibernate.test.collection.list.ListOwner of variable child
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    22
    session.delete(child);
    23
    assertTrue(children.isDirty());
    23
    assertTrue(children.isDirty());
    23
    assertTrue(children.isDirty());
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    23
    assertTrue(children.isDirty());
    24
    session.flush();
    24
    session.flush();
    25
    children.clear();
    25
    children.clear();
    25
    children.clear();
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public void clear()
    25
    children.clear();
    26
    assertFalse(children.isDirty());
    26
    assertFalse(children.isDirty());
    26
    assertFalse(children.isDirty());
    Differences
    Expression1Expression2Difference
    org.hibernate.collection.PersistentBagorg.hibernate.collection.PersistentListSUBCLASS_TYPE_MISMATCH
    26
    assertFalse(children.isDirty());
    27
    session.delete(parent);
    27
    session.delete(parent);
    27
    session.delete(parent);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.collection.bag.BagOwnerorg.hibernate.test.collection.list.ListOwnerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    • Make classes org.hibernate.test.collection.bag.BagOwner and org.hibernate.test.collection.list.ListOwner extend a common superclass
    27
    session.delete(parent);
    28
    session.getTransaction().commit();
    28
    session.getTransaction().commit();
    29
    session.close();
    29
    session.close();
    Precondition Violations (24)
    Row Violation
    1Unmatched statement ListOwner parent=new ListOwner("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement BagOwner parent=new BagOwner("root"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement ListOwner child=new ListOwner("c1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement BagOwner child=new BagOwner("c1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Type org.hibernate.test.collection.bag.BagOwner of variable child does not match with type org.hibernate.test.collection.list.ListOwner of variable child
    6Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    7Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    8Type org.hibernate.test.collection.bag.BagOwner of variable child does not match with type org.hibernate.test.collection.list.ListOwner of variable child
    9Unmatched statement ListOwner otherChild=new ListOwner("c2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement BagOwner otherChild=new BagOwner("c2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    12Expression (PersistentBag)parent.getChildren() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression (PersistentList)parent.getChildren() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent
    15Type org.hibernate.test.collection.bag.BagOwner of variable otherChild does not match with type org.hibernate.test.collection.list.ListOwner of variable otherChild
    16Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public boolean remove(java.lang.Object)
    17Type org.hibernate.test.collection.bag.BagOwner of variable child does not match with type org.hibernate.test.collection.list.ListOwner of variable child
    18Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public boolean retainAll(Collection#RAW)
    19Type org.hibernate.test.collection.bag.BagOwner of variable otherChild does not match with type org.hibernate.test.collection.list.ListOwner of variable otherChild
    20Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public boolean removeAll(Collection#RAW)
    21Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public void clear()
    22Type org.hibernate.test.collection.bag.BagOwner of variable child does not match with type org.hibernate.test.collection.list.ListOwner of variable child
    23Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public void clear()
    24Type org.hibernate.test.collection.bag.BagOwner of variable parent does not match with type org.hibernate.test.collection.list.ListOwner of variable parent