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 sess = openSession(); Lower ls = new Lower(); List list = new ArrayList(); ls.setBag(list); Top s = new Top(); Serializable id = sess.save(ls); sess.save(s); sess.flush(); list.add(s); sess.flush(); sess.connection().commit(); sess.close(); sess = openSession(); ls = (Lower) sess.load(Lower.class, id); assertTrue( ls.getBag().size()==1 ); sess.delete("from java.lang.Object"); sess.flush(); sess.connection().commit(); sess.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/MultiTableTest.java
Method name: void testObjectType() Method name: void testCollectionPointer()
Number of AST nodes: 17 Number of AST nodes: 19
1
Session s = openSession();
1
Session sess = openSession();
2
		GlarchProxy g = new Glarch();
2
		Lower ls = new 
3
		Foo foo = new Foo
3
Lower();
4
();
4
		List list = new ArrayList();
5
		g.setAny(foo
5
		ls.setBag(list);
6
);
6
		Top s = new Top();
7
		Serializable gid = s.save(g);
7
		Serializable id = sess.save(ls);
8
		s.save(foo);
8
		sess.save(
9
		
9
s);
10
		sess.flush();
11
		list.add(s);
10
s.flush();
12
		sess.flush();
11
		s.connection().commit();
13
		sess.connection().commit();
12
		s.close();
14
		sess.close();
13
		s = openSession();
15
		sess = openSession();
14
		g = (GlarchProxy) s.load(Glarch.class, gid);
16
		ls = (Lower) sess.load(Lower.class, id);
15
		assertTrue( g.getAny()!=null && g.getAny() instanceof FooProxy );
17
		assertTrue( ls.get
16
		s.delete( g.getAny() );
17
		s.delete(g);
18
		//s.delete( g.getAny() 
18
Bag().size()==1 );
19
);
19
		sess.delete("from java.lang.Object");
20
		s.flush();
20
		sess.flush();
21
		s.connection().commit();
21
		sess.connection().commit();
22
		s.close();
22
		sess.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 comparisons323
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment7
    Number of unmapped statements in the second code fragment9
    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();
    1
    Session sess = openSession();
    Differences
    Expression1Expression2Difference
    ssessVARIABLE_NAME_MISMATCH
    1
    Session sess = openSession();
                                                    
    2
    Lower ls = new Lower();
    2
    GlarchProxy g = new Glarch();
                                                                
                                                              
    3
    List list = new ArrayList();
    3
    Foo foo = new Foo();
                                              
                                          
    4
    ls.setBag(list);
    Preondition Violations
    Unmatched statement ls.setBag(list); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    ls.setBag(list);
    4
    g.setAny(foo);
    4
    g.setAny(foo);
    Preondition Violations
    Unmatched statement g.setAny(foo); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                      
                                          
    5
    Top s = new Top();
    5
    Serializable gid = s.save(g);
    5
    Serializable gid = s.save(g);
    6
    Serializable id = sess.save(ls);
    Differences
    Expression1Expression2Difference
    gididVARIABLE_NAME_MISMATCH
    glsVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.GlarchProxyorg.hibernate.test.legacy.LowerVARIABLE_TYPE_MISMATCH
    ssessVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Lower of variable ls
    • Make classes org.hibernate.test.legacy.GlarchProxy and org.hibernate.test.legacy.Lower extend a common superclass
    6
    Serializable id = sess.save(ls);
    6
    s.save(foo);
    6
    s.save(foo);
    7
    sess.save(s);
    Differences
    Expression1Expression2Difference
    foosVARIABLE_NAME_MISMATCH
    org.hibernate.test.legacy.Fooorg.hibernate.test.legacy.TopVARIABLE_TYPE_MISMATCH
    ssessVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type org.hibernate.test.legacy.Foo of variable foo does not match with type org.hibernate.test.legacy.Top of variable s
    • Make classes org.hibernate.test.legacy.Foo and org.hibernate.test.legacy.Top extend a common superclass
    7
    sess.save(s);
    7
    s.flush();
    7
    s.flush();
    8
    sess.flush();
    Differences
    Expression1Expression2Difference
    ssessVARIABLE_NAME_MISMATCH
    8
    sess.flush();
                                  
    9
    list.add(s);
                                      
    10
    sess.flush();
    Preondition Violations
    Unmatched statement sess.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    sess.flush();
    8
    s.connection().commit();
    8
    s.connection().commit();
    11
    sess.connection().commit();
    Differences
    Expression1Expression2Difference
    ssessVARIABLE_NAME_MISMATCH
    11
    sess.connection().commit();
    9
    s.close();
    9
    s.close();
    12
    sess.close();
    Differences
    Expression1Expression2Difference
    ssessVARIABLE_NAME_MISMATCH
    12
    sess.close();
    10
    s = openSession();
    10
    s = openSession();
    13
    sess = openSession();
    Differences
    Expression1Expression2Difference
    ssessVARIABLE_NAME_MISMATCH
    13
    sess = openSession();
    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);
                                                                                                                                              
                                                                                    
    14
    ls = (Lower)sess.load(Lower.class, id);
    Preondition Violations
    Unmatched statement ls=(Lower)sess.load(Lower.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    ls = (Lower)sess.load(Lower.class, id);
    13
    s.delete(g.getAny());
    13
    s.delete(g.getAny());
    17
    sess.flush();
    Differences
    Expression1Expression2Difference
    deleteflushMETHOD_INVOCATION_NAME_MISMATCH
    ssessVARIABLE_NAME_MISMATCH
    s.delete(g.getAny())sess.flush()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s.delete(g.getAny()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sess.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.delete(g.getAny()) is a void method call, and thus it cannot be parameterized
    Expression sess.flush() is a void method call, and thus it cannot be parameterized
    Expression s.delete(g.getAny()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sess.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.delete(g.getAny()) is a void method call, and thus it cannot be parameterized
    Expression sess.flush() is a void method call, and thus it cannot be parameterized
    17
    sess.flush();
    14
    s.delete(g);
    14
    s.delete(g);
    Preondition Violations
    Unmatched statement s.delete(g); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
                                                                                    
    15
    assertTrue(ls.getBag().size() == 1);
    15
    s.flush();
    15
    s.flush();
    Preondition Violations
    Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
                                                                                      
    16
    sess.delete("from java.lang.Object");
    Preondition Violations
    Unmatched statement sess.delete("from java.lang.Object"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    sess.delete("from java.lang.Object");
    16
    s.connection().commit();
    16
    s.connection().commit();
    18
    sess.connection().commit();
    Differences
    Expression1Expression2Difference
    ssessVARIABLE_NAME_MISMATCH
    18
    sess.connection().commit();
    17
    s.close();
    17
    s.close();
    19
    sess.close();
    Differences
    Expression1Expression2Difference
    ssessVARIABLE_NAME_MISMATCH
    19
    sess.close();
    Precondition Violations (19)
    Row Violation
    1Unmatched statement ls.setBag(list); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement g.setAny(foo); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Lower of variable ls
    4Type org.hibernate.test.legacy.Foo of variable foo does not match with type org.hibernate.test.legacy.Top of variable s
    5Unmatched statement sess.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched 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
    7Unmatched statement ls=(Lower)sess.load(Lower.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression s.delete(g.getAny()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression sess.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression s.delete(g.getAny()) is a void method call, and thus it cannot be parameterized
    11Expression sess.flush() is a void method call, and thus it cannot be parameterized
    12Expression s.delete(g.getAny()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression sess.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression s.delete(g.getAny()) is a void method call, and thus it cannot be parameterized
    15Expression sess.flush() is a void method call, and thus it cannot be parameterized
    16Unmatched statement s.delete(g); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement s.flush(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Unmatched statement sess.delete("from java.lang.Object"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Clone fragment #1 returns variables gid, s , while Clone fragment #2 returns variables sess, id