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 comparisons228
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment8
    Number of unmapped statements in the second code fragment7
    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());
                                                  
    6
    list.add(new Fee());
    4
    baz.setStringList(l);
    4
    baz.setStringList(l);
    7
    baz.setFees(list);
    Differences
    Expression1Expression2Difference
    setStringListsetFeesMETHOD_INVOCATION_NAME_MISMATCH
    llistVARIABLE_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");
                                    
    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");
                                    
                                  
    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
    l.add("baz");
                                    
    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();
    14
    assertTrue(baz.getFees().size() == 2);
    Differences
    Expression1Expression2Difference
    commitassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    s.connection().commit()assertTrue(baz.getFees().size() == 2)ARGUMENT_NUMBER_MISMATCH
    s.connection()MISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(baz.getFees().size() == 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(baz.getFees().size() == 2) is a void method call, and thus it cannot be parameterized
    Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(baz.getFees().size() == 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(baz.getFees().size() == 2) is a void method call, and thus it cannot be parameterized
    14
    assertTrue(baz.getFees().size() == 2);
    12
    s.close();
    10
    s.close();
    13
    s = openSession();
    11
    s = openSession();
    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"));
    9
    t.commit();
    Differences
    Expression1Expression2Difference
    assertTruecommitMETHOD_INVOCATION_NAME_MISMATCH
    assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar"))t.commit()ARGUMENT_NUMBER_MISMATCH
    tMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")) is a void method call, and thus it cannot be parameterized
    Expression t.commit() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")) is a void method call, and thus it cannot be parameterized
    Expression t.commit() is a void method call, and thus it cannot be parameterized
    9
    t.commit();
                                                          
    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());
    16
    s.delete(baz);
    15
    s.delete(baz);
    17
    s.flush();
                                
    18
    s.connection().commit();
    18
    s.connection().commit();
    16
    assertTrue(!s.iterate("from Fee fee").hasNext());
    Differences
    Expression1Expression2Difference
    commitassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    s.connection().commit()assertTrue(!s.iterate("from Fee fee").hasNext())ARGUMENT_NUMBER_MISMATCH
    s.connection()MISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(!s.iterate("from Fee fee").hasNext()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(!s.iterate("from Fee fee").hasNext()) is a void method call, and thus it cannot be parameterized
    Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(!s.iterate("from Fee fee").hasNext()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(!s.iterate("from Fee fee").hasNext()) is a void method call, and thus it cannot be parameterized
    16
    assertTrue(!s.iterate("from Fee fee").hasNext());
                                  
    17
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    t.commit();
    19
    s.close();
    18
    s.close();
    Precondition Violations (36)
    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
    2Expression baz.setStringList(l) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression baz.setFees(list) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression baz.setStringList(l) is a void method call, and thus it cannot be parameterized
    5Expression baz.setFees(list) is a void method call, and thus it cannot be parameterized
    6Unmatched 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
    7Unmatched statement s.save(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression assertTrue(baz.getFees().size() == 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    13Expression assertTrue(baz.getFees().size() == 2) is a void method call, and thus it cannot be parameterized
    14Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression assertTrue(baz.getFees().size() == 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    17Expression assertTrue(baz.getFees().size() == 2) is a void method call, and thus it cannot be parameterized
    18Unmatched 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
    19Expression assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")) is a void method call, and thus it cannot be parameterized
    21Expression t.commit() is a void method call, and thus it cannot be parameterized
    22Expression assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression assertTrue(baz.getStringList().size() == 3 && baz.getStringList().contains("bar")) is a void method call, and thus it cannot be parameterized
    24Expression t.commit() is a void method call, and thus it cannot be parameterized
    25Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    26Unmatched 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
    27Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression assertTrue(!s.iterate("from Fee fee").hasNext()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    30Expression assertTrue(!s.iterate("from Fee fee").hasNext()) is a void method call, and thus it cannot be parameterized
    31Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    32Expression assertTrue(!s.iterate("from Fee fee").hasNext()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    33Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    34Expression assertTrue(!s.iterate("from Fee fee").hasNext()) is a void method call, and thus it cannot be parameterized
    35Unmatched statement t.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    36Clone fragment #1 returns variables l, s, baz , while Clone fragment #2 returns variables s, list, baz