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(); Parent g = new Parent(); Foo foo = new Foo(); g.setAny(foo); s.save(g); s.save(foo); s.flush(); s.connection().commit(); s.close(); s = openSession(); g = (Parent) s.load( Parent.class, new Long( g.getId() ) ); assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy ); s.delete( g.getAny() ); s.delete(g); 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/ParentChildTest.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
		Serializable id = s.save( new Baz() 
2
		Parent g = new Parent();
3
		Foo foo = new Foo();
4
		g.setAny(foo);
5
		s.save(g);
3
);
6
		s.save(foo);
4
		s.flush();
7
		s.flush();
5
		s.connection().commit();
8
		s.connection().commit();
6
		s.close();
9
		s.close();
7
		s = openSession();
10
		s = openSession();
8
		Baz baz = (Baz) s.load(Baz.class, id);
11
		g = (Parent) s.load( Parent.class, 
9
		Set foos = baz.getFooSet();
10
		assertTrue( foos.size()==0 );
11
		Foo foo = new Foo();
12
		foos.add(foo);
13
		s.save(foo);
14
		s.flush(
12
new Long( g.getId() ) );
15
);
13
		assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy );
16
		s.delete(foo);
14
		s.delete( g.getAny() );
17
		s.delete(baz);
15
		s.delete(g);
18
		s.flush();
16
		s.flush();
19
		s.connection().commit();
17
		s.connection().commit();
20
		s.close();
18
		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 in different classes having the same super 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
    Parent g = new Parent();
    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);
    11
    foos.add(foo);
                                        
    12
    s.save(foo);
    12
    s.save(foo);
    5
    s.save(g);
    Differences
    Expression1Expression2Difference
    foogVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Fooorg.hibernate.test.legacy.ParentVARIABLE_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.Parent of variable g
    • Make classes org.hibernate.test.legacy.Foo and org.hibernate.test.legacy.Parent extend a common superclass
    5
    s.save(g);
                                  
    6
    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
    6
    s.save(foo);
                                                                                                                  
    11
    g = (Parent)s.load(Parent.class, new Long(g.getId()));
    Preondition Violations
    Unmatched statement g=(Parent)s.load(Parent.class,new Long(g.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    g = (Parent)s.load(Parent.class, new Long(g.getId()));
    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.ParentVARIABLE_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.Parent of variable g
    • Make classes org.hibernate.test.legacy.Foo and org.hibernate.test.legacy.Parent 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 (15)
    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
    3Expression foo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Type org.hibernate.test.legacy.Foo of variable foo does not match with type org.hibernate.test.legacy.Parent of variable g
    5Unmatched statement s.save(foo); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement g=(Parent)s.load(Parent.class,new Long(g.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression s.flush() is a void method call, and thus it cannot be parameterized
    9Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    10Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression s.flush() is a void method call, and thus it cannot be parameterized
    12Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    13Expression foo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Type org.hibernate.test.legacy.Foo of variable foo does not match with type org.hibernate.test.legacy.Parent of variable g
    15Clone fragment #1 returns variables s, foo , while Clone fragment #2 returns variables foo, s