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 comparisons83
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment4
    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
    Baz baz = new Baz();
    2
    Baz baz = new Baz();
    2
    Glarch g1 = new Glarch();
    Differences
    Expression1Expression2Difference
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    bazg1VARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    2
    Glarch g1 = new Glarch();
    3
    Foo foo = new Foo();
    3
    Foo foo = new Foo();
    3
    Glarch g2 = new Glarch();
    Differences
    Expression1Expression2Difference
    org.hibernate.test.legacy.Fooorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    foog2VARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Fooorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    org.hibernate.test.legacy.Fooorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    3
    Glarch g2 = new Glarch();
    4
    List bag = new ArrayList();
    4
    List bag = new ArrayList();
    12
    List l = s.find("from Glarch g where g.next is not null");
    Differences
    Expression1Expression2Difference
    baglVARIABLE_NAME_MISMATCH
    java.util.ArrayListjava.util.ListSUBCLASS_TYPE_MISMATCH
    new ArrayList()s.find("from Glarch g where g.next is not null")TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression s.find("from Glarch g where g.next is not null") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    List l = s.find("from Glarch g where g.next is not null");
    5
    bag.add(foo);
    5
    bag.add(foo);
    Preondition Violations
    Unmatched statement bag.add(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
    6
    baz.setIdFooBag(bag);
    6
    baz.setIdFooBag(bag);
    Preondition Violations
    Unmatched statement baz.setIdFooBag(bag); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    7
    baz.setFoo(foo);
    7
    baz.setFoo(foo);
    4
    g1.setNext(g2);
    Differences
    Expression1Expression2Difference
    foog2VARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Fooorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    setFoosetNextMETHOD_INVOCATION_NAME_MISMATCH
    bazg1VARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression baz.setFoo(foo) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression g1.setNext(g2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression baz.setFoo(foo) is a void method call, and thus it cannot be parameterized
    Expression g1.setNext(g2) is a void method call, and thus it cannot be parameterized
    Expression baz cannot be unified with expression g1 , because common superclass org.hibernate.test.legacy.Named does not declare member(s) public void setFoo(org.hibernate.test.legacy.FooProxy) , public void setNext(org.hibernate.test.legacy.GlarchProxy)
    4
    g1.setNext(g2);
                                        
    5
    g2.setNext(g1);
    Preondition Violations
    Unmatched statement g2.setNext(g1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    g2.setNext(g1);
    8
    s.save(baz);
    8
    s.save(baz);
    6
    s.save(g1);
    Differences
    Expression1Expression2Difference
    bazg1VARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Bazorg.hibernate.test.legacy.GlarchSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression baz cannot be unified with expression g1 , because common superclass type org.hibernate.test.legacy.Named cannot be passed as an argument to public abstract java.io.Serializable save(java.lang.Object) throws org.hibernate.HibernateException
    6
    s.save(g1);
                                
    7
    s.save(g2);
    Preondition Violations
    Unmatched statement s.save(g2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    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();
                                                  
    13
    s.delete(l.get(0));
    Preondition Violations
    Unmatched statement s.delete(l.get(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    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));
    Preondition Violations
    Unmatched statement s.delete(l.get(1)); 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);
    14
    s.delete(baz);
    Preondition Violations
    Unmatched statement s.delete(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                        
    15
    s.flush();
    15
    s.flush();
    16
    s.connection().commit();
    16
    s.connection().commit();
    17
    s.close();
    17
    s.close();
    Precondition Violations (16)
    Row Violation
    1Expression s.find("from Glarch g where g.next is not null") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Unmatched statement bag.add(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement baz.setIdFooBag(bag); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression baz.setFoo(foo) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression g1.setNext(g2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression baz.setFoo(foo) is a void method call, and thus it cannot be parameterized
    7Expression g1.setNext(g2) is a void method call, and thus it cannot be parameterized
    8Expression baz cannot be unified with expression g1 , because common superclass org.hibernate.test.legacy.Named does not declare member(s) public void setFoo(org.hibernate.test.legacy.FooProxy) , public void setNext(org.hibernate.test.legacy.GlarchProxy)
    9Unmatched statement g2.setNext(g1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Expression baz cannot be unified with expression g1 , because common superclass type org.hibernate.test.legacy.Named cannot be passed as an argument to public abstract java.io.Serializable save(java.lang.Object) throws org.hibernate.HibernateException
    11Unmatched statement s.save(g2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement s.delete(l.get(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched 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
    14Unmatched statement s.delete(l.get(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement s.delete(baz); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Clone fragment #1 returns variables foo, bag, baz, s , while Clone fragment #2 returns variables g1, g2, s, l