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 comparisons133
  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
    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();
    2
    Bar bar = new Bar();
    10
    Foo foo = new Foo();
    Differences
    Expression1Expression2Difference
    org.hibernate.test.legacy.Barorg.hibernate.test.legacy.FooSUBCLASS_TYPE_MISMATCH
    barfooVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Barorg.hibernate.test.legacy.FooSUBCLASS_TYPE_MISMATCH
    org.hibernate.test.legacy.Barorg.hibernate.test.legacy.FooSUBCLASS_TYPE_MISMATCH
    10
    Foo foo = new Foo();
    3
    One one = new One();
                                              
    4
    bar.setObject(one);
    4
    bar.setObject(one);
    Preondition Violations
    Unmatched statement bar.setObject(one); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                
    5
    s.save(bar);
    5
    s.save(bar);
    Preondition Violations
    Unmatched statement s.save(bar); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                  
    6
    GlarchProxy g = bar.getComponent().getGlarch();
    6
    GlarchProxy g = bar.getComponent().getGlarch();
    Preondition Violations
    Unmatched statement GlarchProxy g=bar.getComponent().getGlarch(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                    
                                                                              
    7
    Baz baz = (Baz)s.load(Baz.class, id);
    Preondition Violations
    Unmatched statement Baz 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
    7
    Baz baz = (Baz)s.load(Baz.class, id);
    7
    bar.getComponent().setGlarch(null);
    7
    bar.getComponent().setGlarch(null);
    Preondition Violations
    Unmatched statement bar.getComponent().setGlarch(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
                                                            
    8
    Set foos = baz.getFooSet();
    8
    s.delete(g);
    8
    s.delete(g);
    Preondition Violations
    Unmatched statement s.delete(g); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                  
                                                                    
    9
    assertTrue(foos.size() == 0);
                                        
    11
    foos.add(foo);
    Preondition Violations
    Unmatched statement foos.add(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    foos.add(foo);
                                    
    12
    s.save(foo);
    Preondition Violations
    Unmatched statement s.save(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    s.save(foo);
    9
    s.flush();
    13
    s.flush();
    10
    assertTrue(s.contains(one));
    10
    assertTrue(s.contains(one));
    Preondition Violations
    Unmatched statement assertTrue(s.contains(one)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                    
                                        
    14
    s.delete(foo);
    Preondition Violations
    Unmatched statement s.delete(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    s.delete(foo);
    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);
    Preondition Violations
    Unmatched statement Bar bar2=(Bar)s.saveOrUpdateCopy(bar); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                        
    15
    s.flush();
    16
    s.flush();
    16
    s.delete(bar2);
    16
    s.delete(bar2);
    15
    s.delete(baz);
    Differences
    Expression1Expression2Difference
    bar2bazVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Barorg.hibernate.test.legacy.BazVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Bar of variable bar2 does not match with type org.hibernate.test.legacy.Baz of variable baz
    • Make classes org.hibernate.test.legacy.Bar and org.hibernate.test.legacy.Baz extend a common superclass
    15
    s.delete(baz);
    17
    s.flush();
    3
    s.flush();
    18
    s.connection().commit();
    4
    s.connection().commit();
    19
    s.close();
    5
    s.close();
    Precondition Violations (14)
    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
    2Unmatched statement bar.setObject(one); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement s.save(bar); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement GlarchProxy g=bar.getComponent().getGlarch(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement Baz 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
    6Unmatched statement bar.getComponent().setGlarch(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s.delete(g); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement foos.add(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement s.save(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement assertTrue(s.contains(one)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement s.delete(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement Bar bar2=(Bar)s.saveOrUpdateCopy(bar); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Type org.hibernate.test.legacy.Bar of variable bar2 does not match with type org.hibernate.test.legacy.Baz of variable baz
    14Clone fragment #1 returns variables bar, s , while Clone fragment #2 returns variables s, foo