Session s = openSession(); Baz baz = new Baz(); baz.setDefaults(); s.save(baz); s.flush(); s.connection().commit(); s.close(); s = openSession(); baz = (Baz) s.load( Baz.class, baz.getCode() ); ( (FooComponent) baz.getTopComponents().get(0) ).setCount(99); s.flush(); s.connection().commit(); s.close(); s = openSession(); baz = (Baz) s.load( Baz.class, baz.getCode() ); assertTrue( ( (FooComponent) baz.getTopComponents().get(0) ).getCount()==99 ); s.delete(baz); s.flush(); s.connection().commit(); s.close();
Session s = openSession(); Baz baz = new Baz(); baz.setDefaults(); s.save(baz); s.flush(); s.connection().commit(); s.close(); s = openSession(); s.load( Baz.class, baz.getCode() ); s.flush(); s.connection().commit(); s.close(); s = openSession(); baz = (Baz) s.load( Baz.class, baz.getCode() ); 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 testCachedCollection() Method name: void testCollectionCache()
Number of AST nodes: 20 Number of AST nodes: 18
1
Session s = openSession();
1
Session s = openSession();
2
		Baz baz = new Baz();
2
		Baz baz = new Baz();
3
		baz.setDefaults();
3
		baz.setDefaults();
4
		s.save(baz);
4
		s.save(baz);
5
		s.flush();
5
		s.flush();
6
		s.connection().commit();
6
		s.connection().commit();
7
		s.close();
7
		s.close();
8
		s = openSession();
8
		s = openSession();
9
		baz = (Baz) s.load( Baz.class, baz.getCode() );
9
		s.load( Baz.class, baz.getCode() );
10
		( (FooComponent) baz.getTopComponents().get(0) ).setCount(99);
10
		
11
		s.flush();
11
s.flush();
12
		s.connection().commit();
12
		s.connection().commit();
13
		s.close();
13
		s.close();
14
		s = openSession();
14
		s = openSession();
15
		baz = (Baz) s.load( Baz.class, baz.getCode() );
15
		baz = (Baz) s.load( Baz.class, baz.getCode() );
16
		assertTrue( ( (FooComponent) baz.getTopComponents().get(0) ).getCount()==99 );
16
		
17
		s.delete(baz);
17
s.delete(baz);
18
		s.flush();
18
		s.flush();
19
		s.connection().commit();
19
		s.connection().commit();
20
		s.close();
20
		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 comparisons70
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment1
    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
    Baz baz = new Baz();
    2
    Baz baz = new Baz();
    3
    baz.setDefaults();
    3
    baz.setDefaults();
    4
    s.save(baz);
    4
    s.save(baz);
    5
    s.flush();
    5
    s.flush();
    6
    s.connection().commit();
    6
    s.connection().commit();
    7
    s.close();
    7
    s.close();
    8
    s = openSession();
    8
    s = openSession();
                                                                          
    9
    s.load(Baz.class, baz.getCode());
    Preondition Violations
    Unmatched statement 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
    9
    s.load(Baz.class, baz.getCode());
    9
    baz = (Baz)s.load(Baz.class, baz.getCode());
    14
    baz = (Baz)s.load(Baz.class, baz.getCode());
    10
    ((FooComponent)baz.getTopComponents().get(0)).setCount(99);
                                                                                                                                  
    11
    s.flush();
    10
    s.flush();
    12
    s.connection().commit();
    11
    s.connection().commit();
    13
    s.close();
    12
    s.close();
    14
    s = openSession();
    13
    s = openSession();
    15
    baz = (Baz)s.load(Baz.class, baz.getCode());
    15
    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
                                                                                              
    16
    assertTrue(((FooComponent)baz.getTopComponents().get(0)).getCount() == 99);
                                                                                                                                                                  
    17
    s.delete(baz);
    15
    s.delete(baz);
    18
    s.flush();
    16
    s.flush();
    19
    s.connection().commit();
    17
    s.connection().commit();
    20
    s.close();
    18
    s.close();
    Precondition Violations (3)
    Row Violation
    1Unmatched statement 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
    2Unmatched 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
    3Clone fragment #1 returns variables baz, s , while Clone fragment #2 returns variables baz, s