Session s = openSession(); Bar bar = new Bar(); One one = new One(); bar.setObject(one); s.save(bar); GlarchProxy g = bar.getComponent().getGlarch(); bar.getComponent().setGlarch(null); s.delete(g); s.flush(); assertTrue( s.contains(one) ); s.connection().commit(); s.close(); s = openSession(); Bar bar2 = (Bar) s.saveOrUpdateCopy(bar); s.flush(); s.delete(bar2); s.flush(); s.connection().commit(); s.close();
Session s = openSession(); Serializable id = s.save( new Baz() ); s.flush(); s.connection().commit(); s.close(); s = openSession(); Baz baz = (Baz) s.load(Baz.class, id); Set foos = baz.getFooSet(); assertTrue( foos.size()==0 ); Foo foo = new Foo(); foos.add(foo); s.save(foo); s.flush(); s.delete(foo); s.delete(baz); s.flush(); s.connection().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 testSaveOrUpdateCopyAny() Method name: void testEmptyCollection()
Number of AST nodes: 19 Number of AST nodes: 18
1
Session s = openSession();
1
Session s = openSession();
2
		Bar bar = new Bar();
2
		Serializable id = s.save( new Baz() );
3
		One one = new One();
3
		
4
		bar.setObj
4
s.flush();
5
ect(one);
5
		s.connection
6
		s.save(bar);
7
		GlarchProxy g = bar.getComponent().getGlarch();
8
		bar.getComponent().setGlarch(null);
9
		s.delete(g);
10
		s.flush
6
().commit();
7
		s.close();
8
		s = openSession();
9
		Baz baz = (Baz) s.load(Baz.class, id);
11
();
10
		Set foos = baz.getFooSet();
12
		assertTrue( s.contains(one) );
11
		assertTrue( 
13
		s.connection().commit();
14
		s.close();
15
		s = openSession();
16
		Bar bar2 = (Bar) s.saveOrUpdateCopy(bar
12
foos.size()==0 );
13
		Foo foo = new Foo();
14
		foos.add(foo);
17
);
15
		s.save(foo);
18
		s.flush();
16
		s.flush();
19
		s.delete(bar2
17
		s.delete(foo);
20
);
18
		s.delete(baz);
21
		s.flush();
19
		s.flush();
22
		s.connection().commit();
20
		s.connection().commit();
23
		s.close();
21
		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 comparisons162
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment6
    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
    Serializable id = s.save(new Baz());
    Preondition Violations
    Unmatched statement Serializable id=s.save(new Baz()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    Serializable id = s.save(new Baz());
    2
    Bar bar = new Bar();
                                              
    3
    One one = new One();
                                              
    4
    bar.setObject(one);
                                                
    5
    s.save(bar);
    5
    s.save(bar);
    12
    s.save(foo);
    Differences
    Expression1Expression2Difference
    barfooVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Barorg.hibernate.test.legacy.FooSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression foo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    s.save(foo);
    6
    GlarchProxy g = bar.getComponent().getGlarch();
                                                                                                    
    7
    bar.getComponent().setGlarch(null);
    7
    bar.getComponent().setGlarch(null);
    9
    assertTrue(foos.size() == 0);
    Differences
    Expression1Expression2Difference
    setGlarchassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    bar.getComponent()MISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression bar.getComponent().setGlarch(null) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(foos.size() == 0) is a void method call, and thus it cannot be parameterized
    Expression bar.getComponent().setGlarch(null) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(foos.size() == 0) is a void method call, and thus it cannot be parameterized
    9
    assertTrue(foos.size() == 0);
    8
    s.delete(g);
    8
    s.delete(g);
    3
    s.flush();
    Differences
    Expression1Expression2Difference
    deleteflushMETHOD_INVOCATION_NAME_MISMATCH
    s.delete(g)s.flush()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s.delete(g) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.delete(g) is a void method call, and thus it cannot be parameterized
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression s.delete(g) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.delete(g) is a void method call, and thus it cannot be parameterized
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    3
    s.flush();
                              
    5
    s.close();
    Preondition Violations
    Unmatched statement s.close(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    s.close();
                                                                              
    7
    Baz baz = (Baz)s.load(Baz.class, id);
                                                            
    8
    Set foos = baz.getFooSet();
    9
    s.flush();
    13
    s.flush();
    10
    assertTrue(s.contains(one));
    10
    assertTrue(s.contains(one));
    4
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    assertTruecommitMETHOD_INVOCATION_NAME_MISMATCH
    assertTrue(s.contains(one))s.connection().commit()ARGUMENT_NUMBER_MISMATCH
    s.connection()MISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertTrue(s.contains(one)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(s.contains(one)) is a void method call, and thus it cannot be parameterized
    Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(s.contains(one)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(s.contains(one)) is a void method call, and thus it cannot be parameterized
    Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    4
    s.connection().commit();
    11
    s.connection().commit();
    17
    s.connection().commit();
    12
    s.close();
    18
    s.close();
    13
    s = openSession();
    6
    s = openSession();
    14
    Bar bar2 = (Bar)s.saveOrUpdateCopy(bar);
    14
    Bar bar2 = (Bar)s.saveOrUpdateCopy(bar);
    10
    Foo foo = new Foo();
    Differences
    Expression1Expression2Difference
    org.hibernate.test.legacy.Barorg.hibernate.test.legacy.FooSUBCLASS_TYPE_MISMATCH
    bar2fooVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Barorg.hibernate.test.legacy.FooSUBCLASS_TYPE_MISMATCH
    (Bar)s.saveOrUpdateCopy(bar)new Foo()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (Bar)s.saveOrUpdateCopy(bar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    Foo foo = new Foo();
                                        
    11
    foos.add(foo);
                                        
    15
    s.delete(baz);
    15
    s.flush();
    16
    s.flush();
    16
    s.delete(bar2);
    16
    s.delete(bar2);
    14
    s.delete(foo);
    Differences
    Expression1Expression2Difference
    bar2fooVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Barorg.hibernate.test.legacy.FooSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression bar2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression foo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    s.delete(foo);
    17
    s.flush();
    16
    s.flush();
    18
    s.connection().commit();
    17
    s.connection().commit();
    19
    s.close();
    18
    s.close();
    Precondition Violations (27)
    Row Violation
    1Unmatched statement Serializable id=s.save(new Baz()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression foo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression bar.getComponent().setGlarch(null) is a void method call, and thus it cannot be parameterized
    4Expression assertTrue(foos.size() == 0) is a void method call, and thus it cannot be parameterized
    5Expression bar.getComponent().setGlarch(null) is a void method call, and thus it cannot be parameterized
    6Expression assertTrue(foos.size() == 0) is a void method call, and thus it cannot be parameterized
    7Expression s.delete(g) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression s.delete(g) is a void method call, and thus it cannot be parameterized
    10Expression s.flush() is a void method call, and thus it cannot be parameterized
    11Expression s.delete(g) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression s.delete(g) is a void method call, and thus it cannot be parameterized
    14Expression s.flush() is a void method call, and thus it cannot be parameterized
    15Unmatched statement s.close(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Expression assertTrue(s.contains(one)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression assertTrue(s.contains(one)) is a void method call, and thus it cannot be parameterized
    19Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    20Expression assertTrue(s.contains(one)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression s.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression assertTrue(s.contains(one)) is a void method call, and thus it cannot be parameterized
    23Expression s.connection().commit() is a void method call, and thus it cannot be parameterized
    24Expression (Bar)s.saveOrUpdateCopy(bar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression bar2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression foo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Clone fragment #1 returns variables , while Clone fragment #2 returns variables s, foo