Session s = openSession(); Baz baz = new Baz(); List l = new ArrayList(); baz.setStringList(l); l.add("foo"); Serializable id = s.save(baz); l.add("bar"); s.flush(); l.add("baz"); s.flush(); s.connection().commit(); s.close(); s = openSession(); baz = (Baz) s.load(Baz.class, id); assertTrue( baz.getStringList().size()==3 && baz.getStringList().contains("bar") ); s.delete(baz); s.flush(); s.connection().commit(); s.close();
Session s = openSession(); Transaction t = s.beginTransaction(); Baz baz = new Baz(); List list = new ArrayList(); list.add( new Fee() ); list.add( new Fee() ); baz.setFees(list); s.save(baz); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); baz = (Baz) s.load( Baz.class, baz.getCode() ); assertTrue( baz.getFees().size()==2 ); s.delete(baz); assertTrue( !s.iterate("from Fee fee").hasNext() ); t.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/legacy/FooBarTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
Method name: void testLateCollectionAdd() Method name: void testCascadeSave()
Number of AST nodes: 19 Number of AST nodes: 18
1
Session s = openSession();
1
Session s = openSession();
2
		
2
		Transaction t = s.beginTransaction();
3
Baz baz = new Baz();
3
		Baz baz = new Baz();
4
		List l = new ArrayList();
4
		List list = new ArrayList();
5
		baz.setStringList(l);
5
		
6
		l.add("foo");
7
		Serializable id = s.save(baz);
6
list.add( new Fee() );
8
		l.add("bar");
7
		list.add(
9
		s.flush();
10
		l.add("
8
 new Fee() );
9
		baz.setFees(list);
11
baz");
10
		s.save(baz);
12
		s.flush();
11
		
13
		s.connection().commit();
12
t.commit();
14
		s.close();
13
		s.close();
15
		s = openSession();
14
		s = openSession();
16
		
15
		t = s.beginTransaction();
17
baz = (Baz) s.load(Baz.class, id);
16
		baz = (Baz) s.load( Baz.class, baz.getCode() );
18
		assertTrue( baz.getStringList().size()==3 && baz.getStringList().contains("bar") );
17
		assertTrue( baz.getFees().size()==
19
		s.delete(baz);
20
		s.flush();
21
		s.connection()
18
2 );
19
		s.delete(baz);
20
		assertTrue( !s.iterate("from Fee fee").hasNext() );
22
.commit();
21
		t.commit();
23
		s.close();
22
		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 declared in the same class
Number of node comparisons206
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment11
    Number of unmapped statements in the second code fragment10
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
                                                                                
    2
    Transaction t = s.beginTransaction();
    Preondition Violations
    Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    Transaction t = s.beginTransaction();
    2
    Baz baz = new Baz();
    3
    Baz baz = new Baz();
    3
    List l = new ArrayList();
    3
    List l = new ArrayList();
    4
    List list = new ArrayList();
    Differences
    Expression1Expression2Difference
    llistVARIABLE_NAME_MISMATCH
    4
    List list = new ArrayList();
                                                  
    5
    list.add(new Fee());
    Preondition Violations
    Unmatched statement list.add(new Fee()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    list.add(new Fee());
    4
    baz.setStringList(l);
    4
    baz.setStringList(l);
    7
    baz.setFees(list);
    Differences
    Expression1Expression2Difference
    llistVARIABLE_NAME_MISMATCH
    setStringListsetFeesMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression baz.setStringList(l) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression baz.setFees(list) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression baz.setStringList(l) is a void method call, and thus it cannot be parameterized
    Expression baz.setFees(list) is a void method call, and thus it cannot be parameterized
    7
    baz.setFees(list);
    5
    l.add("foo");
    5
    l.add("foo");
    Preondition Violations
    Unmatched statement l.add("foo"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
                                                  
    6
    list.add(new Fee());
    Preondition Violations
    Unmatched statement list.add(new Fee()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    list.add(new Fee());
    6
    Serializable id = s.save(baz);
    6
    Serializable id = s.save(baz);
    Preondition Violations
    Unmatched statement Serializable id=s.save(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                  
    7
    l.add("bar");
    7
    l.add("bar");
    Preondition Violations
    Unmatched statement l.add("bar"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
                                  
    8
    s.save(baz);
    Preondition Violations
    Unmatched statement s.save(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    s.save(baz);
    8
    s.flush();
    8
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                              
                                
    9
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9
    t.commit();
    9
    l.add("baz");
    9
    l.add("baz");
    Preondition Violations
    Unmatched statement l.add("baz"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
    10
    s.flush();
    10
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
    11
    s.connection().commit();
    11
    s.connection().commit();
    Preondition Violations
    Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    12
    s.close();
    10
    s.close();
    13
    s = openSession();
    11
    s = openSession();
                                                          
    12
    t = s.beginTransaction();
    Preondition Violations
    Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    t = s.beginTransaction();
                                                                                              
    13
    baz = (Baz)s.load(Baz.class, baz.getCode());
    Preondition Violations
    Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    baz = (Baz)s.load(Baz.class, baz.getCode());
                                                                                        
    14
    assertTrue(baz.getFees().size() == 2);
    Preondition Violations
    Unmatched statement assertTrue(baz.getFees().size() == 2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    assertTrue(baz.getFees().size() == 2);
    14
    baz = (Baz)s.load(Baz.class, id);
    14
    baz = (Baz)s.load(Baz.class, id);
    Preondition Violations
    Unmatched statement baz=(Baz)s.load(Baz.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
    15
    assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar"));
    15
    assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar"));
    Preondition Violations
    Unmatched statement assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                  
    16
    s.delete(baz);
    15
    s.delete(baz);
                                                                                                              
    16
    assertTrue(!s.iterate("from Fee fee").hasNext());
    Preondition Violations
    Unmatched statement assertTrue(!s.iterate("from Fee fee").hasNext()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    assertTrue(!s.iterate("from Fee fee").hasNext());
                                  
    17
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    17
    t.commit();
    17
    s.flush();
    17
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
    18
    s.connection().commit();
    18
    s.connection().commit();
    Preondition Violations
    Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    19
    s.close();
    18
    s.close();
    Precondition Violations (26)
    Row Violation
    1Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement list.add(new Fee()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression baz.setStringList(l) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression baz.setFees(list) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression baz.setStringList(l) is a void method call, and thus it cannot be parameterized
    6Expression baz.setFees(list) is a void method call, and thus it cannot be parameterized
    7Unmatched statement l.add("foo"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement list.add(new Fee()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement Serializable id=s.save(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement l.add("bar"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement s.save(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    14Unmatched statement l.add("baz"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement assertTrue(baz.getFees().size() == 2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement baz=(Baz)s.load(Baz.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21Unmatched statement assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement assertTrue(!s.iterate("from Fee fee").hasNext()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    24Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25Unmatched statement s.connection().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    26Clone fragment #1 returns variables l, s, baz , while Clone fragment #2 returns variables s, list, baz