Session s = openSession(); Baz baz = new Baz(); Foo foo = new Foo(); List bag = new ArrayList(); bag.add(foo); baz.setIdFooBag(bag); baz.setFoo(foo); s.save(baz); 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();
Session s = openSession(); Glarch g1 = new Glarch(); Glarch g2 = new Glarch(); g1.setNext(g2); g2.setNext(g1); s.save(g1); s.save(g2); s.flush(); s.connection().commit(); s.close(); s = openSession(); List l = s.find("from Glarch g where g.next is not null"); s.delete( l.get(0) ); s.delete( l.get(1) ); 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 testForeignKeys() Method name: void testNoForeignKeyViolations()
Number of AST nodes: 17 Number of AST nodes: 17
1
Session s = openSession();
1
Session s = openSession();
2
		Baz baz = new Baz();
2
		
3
		Foo foo
3
Glarch g1 = new Glarch();
4
 = new Foo();
4
		Glarch g2 = new 
5
		List bag = new ArrayList();
6
		bag.add(foo
5
Glarch();
7
);
6
		g1.setNext(g2);
8
		baz.setIdFooBag(bag);
7
		g2.set
9
		baz.setFoo(foo
8
Next(g1);
10
);
9
		s.save(g1);
11
		s.save(baz);
10
		s.save(g2);
12
		s.flush();
11
		s.flush();
13
		s.connection().commit();
12
		s.connection().commit();
14
		s.close();
13
		s.close();
15
		s = openSession();
14
		s = openSession();
16
		baz = (Baz) s.load( Baz.class, baz.getCode(
15
		List l = s.find("from Glarch g where g.next is not null");
17
) );
16
		s.delete( l.get(0) );
18
		s.delete(baz);
17
		s.delete( l.get(1) );
19
		s.flush();
18
		s.flush();
20
		s.connection().commit();
19
		s.connection().commit();
21
		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 comparisons133
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment8
    Number of unmapped statements in the second code fragment8
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
                                                        
    2
    Glarch g1 = new Glarch();
    2
    Baz baz = new Baz();
                                              
                                                        
    3
    Glarch g2 = new Glarch();
    3
    Foo foo = new Foo();
                                              
                                        
    4
    g1.setNext(g2);
    4
    List bag = new ArrayList();
                                                            
                                        
    5
    g2.setNext(g1);
    5
    bag.add(foo);
                                    
                                
    6
    s.save(g1);
    Preondition Violations
    Unmatched statement s.save(g1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    s.save(g1);
    6
    baz.setIdFooBag(bag);
                                                    
    7
    baz.setFoo(foo);
                                          
    8
    s.save(baz);
    8
    s.save(baz);
    7
    s.save(g2);
    Differences
    Expression1Expression2Difference
    bazg2VARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.GlarchVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.legacy.Glarch of variable g2
    • Make classes org.hibernate.test.legacy.Baz and org.hibernate.test.legacy.Glarch extend a common superclass
    7
    s.save(g2);
    9
    s.flush();
    8
    s.flush();
    10
    s.connection().commit();
    9
    s.connection().commit();
    11
    s.close();
    10
    s.close();
    12
    s = openSession();
    11
    s = openSession();
                                                                                                                            
    12
    List l = s.find("from Glarch g where g.next is not null");
                                                  
    13
    s.delete(l.get(0));
    13
    baz = (Baz)s.load(Baz.class, baz.getCode());
    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
                                                                                              
                                                  
    14
    s.delete(l.get(1));
    14
    s.delete(baz);
                                        
    15
    s.flush();
    15
    s.flush();
    16
    s.connection().commit();
    16
    s.connection().commit();
    17
    s.close();
    17
    s.close();
    Precondition Violations (3)
    Row Violation
    1Unmatched statement s.save(g1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Type org.hibernate.test.legacy.Baz of variable baz does not match with type org.hibernate.test.legacy.Glarch of variable g2
    3Unmatched 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