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();
Session s = openSession(); GlarchProxy g = new Glarch(); Foo foo = new Foo(); g.setAny(foo); Serializable gid = s.save(g); s.save(foo); s.flush(); s.connection().commit(); s.close(); s = openSession(); g = (GlarchProxy) s.load(Glarch.class, gid); assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy ); s.delete( g.getAny() ); s.delete(g); //s.delete( g.getAny() ); 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 testEmptyCollection() Method name: void testObjectType()
Number of AST nodes: 18 Number of AST nodes: 17
1
Session s = openSession();
1
Session s = openSession();
2
		
2
		GlarchProxy g = new Glarch();
3
		Foo foo = new Foo();
4
		g.setAny(foo);
3
Serializable id = s.save( new Baz() 
5
		Serializable gid = s.save(g);
4
);
6
		s.save(foo);
5
		s.flush();
7
		s.flush();
6
		s.connection().commit();
8
		s.connection().commit();
7
		s.close();
9
		s.close();
8
		s = openSession();
10
		s = openSession();
9
		Baz baz = (Baz) s.load(Baz.class, id);
11
		g = (GlarchProxy) s.load(Glarch.class, gid);
10
		Set foos = baz.getFooSet();
12
		
11
		assertTrue( foos.size()==0 );
13
assertTrue( 
12
		Foo foo = new Foo();
13
		foos.add(foo);
14
		s.save(foo);
15
		s.flush(
14
g.getAny()!=null && g.getAny() instanceof FooProxy );
16
);
15
		s.delete( g.getAny() );
17
		s.delete(foo);
16
		s.delete(g);
18
		s.delete(baz);
17
		//s.delete( g.getAny() );
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 comparisons127
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment5
    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
    GlarchProxy g = new Glarch();
    2
    Serializable id = s.save(new Baz());
    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
                                                                              
    3
    s.flush();
    7
    s.flush();
    4
    s.connection().commit();
    8
    s.connection().commit();
    5
    s.close();
    9
    s.close();
    6
    s = openSession();
    10
    s = openSession();
    7
    Baz baz = (Baz)s.load(Baz.class, id);
                                                                              
    8
    Set foos = baz.getFooSet();
                                                            
    9
    assertTrue(foos.size() == 0);
                                                                    
    10
    Foo foo = new Foo();
    3
    Foo foo = new Foo();
                                      
    4
    g.setAny(foo);
    Preondition Violations
    Unmatched statement g.setAny(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    g.setAny(foo);
                                                                
    5
    Serializable gid = s.save(g);
    Preondition Violations
    Unmatched statement Serializable gid=s.save(g); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    Serializable gid = s.save(g);
    11
    foos.add(foo);
                                        
    12
    s.save(foo);
    6
    s.save(foo);
                                                                                            
    11
    g = (GlarchProxy)s.load(Glarch.class, gid);
    Preondition Violations
    Unmatched statement g=(GlarchProxy)s.load(Glarch.class,gid); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    g = (GlarchProxy)s.load(Glarch.class, gid);
    13
    s.flush();
    13
    s.flush();
    12
    assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy);
    Differences
    Expression1Expression2Difference
    flushassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    s.flush()assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy)ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    12
    assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy);
                                                      
    13
    s.delete(g.getAny());
    14
    s.delete(foo);
    14
    s.delete(foo);
    14
    s.delete(g);
    Differences
    Expression1Expression2Difference
    foogVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Fooorg.hibernate.test.legacy.GlarchProxyVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression foo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.legacy.Foo of variable foo does not match with type org.hibernate.test.legacy.GlarchProxy of variable g
    • Make classes org.hibernate.test.legacy.Foo and org.hibernate.test.legacy.GlarchProxy extend a common superclass
    14
    s.delete(g);
    15
    s.delete(baz);
                                        
    16
    s.flush();
    15
    s.flush();
    17
    s.connection().commit();
    16
    s.connection().commit();
    18
    s.close();
    17
    s.close();
    Precondition Violations (13)
    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 g.setAny(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement Serializable gid=s.save(g); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement g=(GlarchProxy)s.load(Glarch.class,gid); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression s.flush() is a void method call, and thus it cannot be parameterized
    7Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    8Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression s.flush() is a void method call, and thus it cannot be parameterized
    10Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    11Expression foo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Type org.hibernate.test.legacy.Foo of variable foo does not match with type org.hibernate.test.legacy.GlarchProxy of variable g
    13Clone fragment #1 returns variables s, foo , while Clone fragment #2 returns variables foo, s