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();
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 testObjectType() Method name: void testObjectType()
Number of AST nodes: 17 Number of AST nodes: 17
1
Session s = openSession();
1
Session s = openSession();
2
		GlarchProxy g = new Glarch();
2
		Parent g = new Parent();
3
		Foo foo = new Foo();
3
		Foo foo = new Foo();
4
		g.setAny(foo);
4
		g.setAny(foo);
5
		Serializable gid = s.save(g);
5
		s.save(g);
6
		s.save(foo);
6
		s.save(foo);
7
		s.flush();
7
		s.flush();
8
		s.connection().commit();
8
		s.connection().commit();
9
		s.close();
9
		s.close();
10
		s = openSession();
10
		s = openSession();
11
		g = (GlarchProxy) s.load(Glarch.class, gid);
11
		g = (Parent) s.load( Parent.class, new Long( g.getId() ) );
12
		assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy );
12
		assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy );
13
		s.delete( g.getAny() );
13
		s.delete( g.getAny() );
14
		s.delete(g);
14
		s.delete(g);
15
		//s.delete( g.getAny() );
15
		
16
		s.flush();
16
s.flush();
17
		s.connection().commit();
17
		s.connection().commit();
18
		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 comparisons99
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    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
    Parent g = new Parent();
    2
    GlarchProxy g = new Glarch();
                                                                
    3
    Foo foo = new Foo();
    3
    Foo foo = new Foo();
    4
    g.setAny(foo);
    4
    g.setAny(foo);
    4
    g.setAny(foo);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.legacy.GlarchProxyorg.hibernate.test.legacy.ParentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    • Make classes org.hibernate.test.legacy.GlarchProxy and org.hibernate.test.legacy.Parent extend a common superclass
    4
    g.setAny(foo);
                              
    5
    s.save(g);
    Preondition Violations
    Unmatched statement s.save(g); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    s.save(g);
    5
    Serializable gid = s.save(g);
    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
                                                                
    6
    s.save(foo);
    6
    s.save(foo);
    7
    s.flush();
    7
    s.flush();
    8
    s.connection().commit();
    8
    s.connection().commit();
    9
    s.close();
    9
    s.close();
    10
    s = openSession();
    10
    s = openSession();
                                                                                                                  
    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()));
    11
    g = (GlarchProxy)s.load(Glarch.class, gid);
    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
                                                                                            
    12
    assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy);
    12
    assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy);
    12
    assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.legacy.GlarchProxyorg.hibernate.test.legacy.ParentVARIABLE_TYPE_MISMATCH
    org.hibernate.test.legacy.GlarchProxyorg.hibernate.test.legacy.ParentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    • Make classes org.hibernate.test.legacy.GlarchProxy and org.hibernate.test.legacy.Parent extend a common superclass
    Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    • Make classes org.hibernate.test.legacy.GlarchProxy and org.hibernate.test.legacy.Parent extend a common superclass
    12
    assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy);
    13
    s.delete(g.getAny());
    13
    s.delete(g.getAny());
    13
    s.delete(g.getAny());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.legacy.GlarchProxyorg.hibernate.test.legacy.ParentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    • Make classes org.hibernate.test.legacy.GlarchProxy and org.hibernate.test.legacy.Parent extend a common superclass
    13
    s.delete(g.getAny());
    14
    s.delete(g);
    14
    s.delete(g);
    14
    s.delete(g);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.legacy.GlarchProxyorg.hibernate.test.legacy.ParentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    • Make classes org.hibernate.test.legacy.GlarchProxy and org.hibernate.test.legacy.Parent extend a common superclass
    14
    s.delete(g);
    15
    s.flush();
    15
    s.flush();
    16
    s.connection().commit();
    16
    s.connection().commit();
    17
    s.close();
    17
    s.close();
    Precondition Violations (9)
    Row Violation
    1Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    2Unmatched statement s.save(g); 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=(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
    5Unmatched 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
    6Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    7Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    8Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g
    9Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Parent of variable g