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 statements12
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment7
    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);
    4
    g.setAny(foo);
                                      
                                          
    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);
    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);
    12
    assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy);
    18
    sess.connection().commit();
    Differences
    Expression1Expression2Difference
    assertTruecommitMETHOD_INVOCATION_NAME_MISMATCH
    assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy)sess.connection().commit()ARGUMENT_NUMBER_MISMATCH
    sess.connection()MISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression sess.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    Expression sess.connection().commit() is a void method call, and thus it cannot be parameterized
    Expression sess.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    Expression sess.connection().commit() is a void method call, and thus it cannot be parameterized
    18
    sess.connection().commit();
    13
    s.delete(g.getAny());
    13
    s.delete(g.getAny());
    10
    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
    10
    sess.flush();
                                                                                    
    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);
    14
    s.delete(g);
    14
    s.delete(g);
    17
    sess.flush();
    Differences
    Expression1Expression2Difference
    deleteflushMETHOD_INVOCATION_NAME_MISMATCH
    ssessVARIABLE_NAME_MISMATCH
    s.delete(g)sess.flush()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s.delete(g) 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) 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) 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) 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();
    15
    s.flush();
    15
    s.flush();
    15
    assertTrue(ls.getBag().size() == 1);
    Differences
    Expression1Expression2Difference
    flushassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    s.flush()assertTrue(ls.getBag().size() == 1)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(ls.getBag().size() == 1) 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(ls.getBag().size() == 1) is a void method call, and thus it cannot be parameterized
    15
    assertTrue(ls.getBag().size() == 1);
                                                                                      
    16
    sess.delete("from java.lang.Object");
    16
    s.connection().commit();
                                                            
    17
    s.close();
    17
    s.close();
    19
    sess.close();
    Differences
    Expression1Expression2Difference
    ssessVARIABLE_NAME_MISMATCH
    19
    sess.close();
    Precondition Violations (33)
    Row Violation
    1Type org.hibernate.test.legacy.GlarchProxy of variable g does not match with type org.hibernate.test.legacy.Lower of variable ls
    2Type org.hibernate.test.legacy.Foo of variable foo does not match with type org.hibernate.test.legacy.Top of variable s
    3Unmatched 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
    4Expression sess.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    6Expression sess.connection().commit() is a void method call, and thus it cannot be parameterized
    7Expression sess.connection().commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression assertTrue(g.getAny() != null && g.getAny() instanceof FooProxy) is a void method call, and thus it cannot be parameterized
    9Expression sess.connection().commit() is a void method call, and thus it cannot be parameterized
    10Expression s.delete(g.getAny()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression sess.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression s.delete(g.getAny()) is a void method call, and thus it cannot be parameterized
    13Expression sess.flush() is a void method call, and thus it cannot be parameterized
    14Expression s.delete(g.getAny()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression sess.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression s.delete(g.getAny()) is a void method call, and thus it cannot be parameterized
    17Expression sess.flush() is a void method call, and thus it cannot be parameterized
    18Unmatched 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
    19Expression s.delete(g) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression sess.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression s.delete(g) is a void method call, and thus it cannot be parameterized
    22Expression sess.flush() is a void method call, and thus it cannot be parameterized
    23Expression s.delete(g) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression sess.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression s.delete(g) is a void method call, and thus it cannot be parameterized
    26Expression sess.flush() is a void method call, and thus it cannot be parameterized
    27Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression s.flush() is a void method call, and thus it cannot be parameterized
    29Expression assertTrue(ls.getBag().size() == 1) is a void method call, and thus it cannot be parameterized
    30Expression s.flush() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Expression s.flush() is a void method call, and thus it cannot be parameterized
    32Expression assertTrue(ls.getBag().size() == 1) is a void method call, and thus it cannot be parameterized
    33Clone fragment #1 returns variables gid, s , while Clone fragment #2 returns variables id, sess