Session session = openSession(); session.beginTransaction(); Parent parent = new Parent( "p1" ); session.save( parent ); session.getTransaction().commit(); session.close(); // Now, reload the parent and test adding children session = openSession(); session.beginTransaction(); parent = ( Parent ) session.get( Parent.class, parent.getName() ); parent.addChild( "c1" ); parent.addChild( "c2" ); session.getTransaction().commit(); session.close(); assertEquals( 2, parent.getChildren().size() ); session = openSession(); session.beginTransaction(); session.delete( parent ); session.getTransaction().commit(); session.close();
Session s = openSession(); s.beginTransaction(); Parent p = new Parent( "p" ); p.getChildren().add( new Child( "c" ) ); s.save( p ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); p = ( Parent ) s.get( Parent.class, "p" ); // evict... s.evict( p ); // now try to reattach... s.update( p ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.delete( p ); s.getTransaction().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/collection/map/PersistentMapTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/reattachment/CollectionReattachmentTest.java
Method name: void testPutAgainstUninitializedMap() Method name: void testUpdateOwnerAfterEvict()
Number of AST nodes: 19 Number of AST nodes: 19
1
Session session = openSession();
1
Session s = openSession();
2
		session.beginTransaction();
2
		s.beginTransaction();
3
		Parent parent = new Parent( "p1" );
3
		Parent p = new Parent( "p" );
4
		session
4
		p.getChildren().add( new Child( "c" ) );
5
.save( parent );
5
		s.save( p );
6
		session.getTransaction().commit();
6
		s.getTransaction().commit();
7
		session.close();
7
		s.close();
8
		// Now, reload the parent and test adding children
8
		
9
		session = openSession();
9
s = openSession();
10
		session.beginTransaction();
10
		s.beginTransaction();
11
		parent = ( Parent ) session.get( Parent.class, parent.getName() );
11
		p = ( Parent ) s.get( Parent.class, 
12
		parent.addChild( "c1" );
13
		parent.addChild( "c2"
12
"p" );
13
		// evict...
14
		s.evict( p );
15
		// now try to reattach...
14
 );
16
		s.update( p );
15
		session.getTransaction().commit();
17
		s.getTransaction().commit();
16
		session.close();
18
		s.close();
17
		assertEquals( 2, parent.getChildren().size() );
19
		
18
		session = openSession();
20
s = openSession();
19
		session.beginTransaction();
21
		s.beginTransaction();
20
		session.delete( parent );
22
		s.delete( p );
21
		session.getTransaction().commit();
23
		s.getTransaction().commit();
22
		session.close();
24
		s.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 comparisons361
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session session = openSession();
    1
    Session session = openSession();
    1
    Session s = openSession();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    1
    Session s = openSession();
    2
    session.beginTransaction();
    2
    session.beginTransaction();
    2
    s.beginTransaction();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    2
    s.beginTransaction();
                                                            
    3
    Parent p = new Parent("p");
    Preondition Violations
    Unmatched statement Parent p=new Parent("p"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    Parent p = new Parent("p");
    3
    Parent parent = new Parent("p1");
    3
    Parent parent = new Parent("p1");
    Preondition Violations
    Unmatched statement Parent parent=new Parent("p1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                        
                                                                                  
    4
    p.getChildren().add(new Child("c"));
    4
    session.save(parent);
    4
    session.save(parent);
    5
    s.save(p);
    Differences
    Expression1Expression2Difference
    parentpVARIABLE_NAME_MISMATCH
    org.hibernate.test.collection.map.Parentorg.hibernate.test.reattachment.ParentVARIABLE_TYPE_MISMATCH
    sessionsVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.map.Parent of variable parent does not match with type org.hibernate.test.reattachment.Parent of variable p
    • Make classes org.hibernate.test.collection.map.Parent and org.hibernate.test.reattachment.Parent extend a common superclass
    5
    s.save(p);
    5
    session.getTransaction().commit();
    5
    session.getTransaction().commit();
    6
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    6
    s.getTransaction().commit();
    6
    session.close();
    6
    session.close();
    7
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    7
    s.close();
    7
    session = openSession();
    7
    session = openSession();
    8
    s = openSession();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    8
    s = openSession();
    8
    session.beginTransaction();
    8
    session.beginTransaction();
    9
    s.beginTransaction();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    9
    s.beginTransaction();
    9
    parent = (Parent)session.get(Parent.class, parent.getName());
    9
    parent = (Parent)session.get(Parent.class, parent.getName());
    Preondition Violations
    Unmatched statement parent=(Parent)session.get(Parent.class,parent.getName()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                              
                                                                                
    10
    p = (Parent)s.get(Parent.class, "p");
    Preondition Violations
    Unmatched statement p=(Parent)s.get(Parent.class,"p"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    p = (Parent)s.get(Parent.class, "p");
    10
    parent.addChild("c1");
                                                        
                                  
    11
    s.evict(p);
    Preondition Violations
    Unmatched statement s.evict(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    s.evict(p);
    11
    parent.addChild("c2");
                                                        
                                    
    12
    s.update(p);
    Preondition Violations
    Unmatched statement s.update(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    s.update(p);
    12
    session.getTransaction().commit();
    12
    session.getTransaction().commit();
    13
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    13
    s.getTransaction().commit();
    13
    session.close();
    13
    session.close();
    14
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    14
    s.close();
    14
    assertEquals(2, parent.getChildren().size());
                                                                                                    
    15
    session = openSession();
    15
    session = openSession();
    15
    s = openSession();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    15
    s = openSession();
    16
    session.beginTransaction();
    16
    session.beginTransaction();
    16
    s.beginTransaction();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    16
    s.beginTransaction();
    17
    session.delete(parent);
    17
    session.delete(parent);
    17
    s.delete(p);
    Differences
    Expression1Expression2Difference
    parentpVARIABLE_NAME_MISMATCH
    org.hibernate.test.collection.map.Parentorg.hibernate.test.reattachment.ParentVARIABLE_TYPE_MISMATCH
    sessionsVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type org.hibernate.test.collection.map.Parent of variable parent does not match with type org.hibernate.test.reattachment.Parent of variable p
    • Make classes org.hibernate.test.collection.map.Parent and org.hibernate.test.reattachment.Parent extend a common superclass
    17
    s.delete(p);
    18
    session.getTransaction().commit();
    18
    session.getTransaction().commit();
    18
    s.getTransaction().commit();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    18
    s.getTransaction().commit();
    19
    session.close();
    19
    session.close();
    19
    s.close();
    Differences
    Expression1Expression2Difference
    sessionsVARIABLE_NAME_MISMATCH
    19
    s.close();
    Precondition Violations (8)
    Row Violation
    1Unmatched statement Parent p=new Parent("p"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement Parent parent=new Parent("p1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Type org.hibernate.test.collection.map.Parent of variable parent does not match with type org.hibernate.test.reattachment.Parent of variable p
    4Unmatched statement parent=(Parent)session.get(Parent.class,parent.getName()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement p=(Parent)s.get(Parent.class,"p"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement s.evict(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s.update(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Type org.hibernate.test.collection.map.Parent of variable parent does not match with type org.hibernate.test.reattachment.Parent of variable p