Session s = openSession(); s.beginTransaction(); Parent p = new Parent( "p" ); s.save( p ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); p = ( Parent ) s.load( Parent.class, "p" ); // clear... s.clear(); // now try to reattach... s.update( p ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.delete( p ); s.getTransaction().commit(); s.close();
Session s = openSession(); s.beginTransaction(); Parent p = new Parent( "p" ); s.save( p ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); p = ( Parent ) s.load( Parent.class, "p" ); // evict... s.evict( p ); // now try to reattach... s.update( p ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.delete( p ); s.getTransaction().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/reattachment/ProxyReattachmentTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/reattachment/ProxyReattachmentTest.java
Method name: void testUpdateAfterClear() Method name: void testUpdateAfterEvict()
Number of AST nodes: 18 Number of AST nodes: 18
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		s.beginTransaction();
3
		Parent p = new Parent( "p" );
3
		Parent p = new Parent( "p" );
4
		s.save( p );
4
		s.save( p );
5
		s.getTransaction().commit();
5
		s.getTransaction().commit();
6
		s.close();
6
		s.close();
7
		s = openSession();
7
		s = openSession();
8
		s.beginTransaction();
8
		s.beginTransaction();
9
		p = ( Parent ) s.load( Parent.class, "p" );
9
		p = ( Parent ) s.load( Parent.class, "p" );
10
		// clear...
10
		// evict...
11
		s.clear();
11
		s.evict( p );
12
		// now try to reattach...
12
		// now try to reattach...
13
		s.update( p );
13
		s.update( p );
14
		s.getTransaction().commit();
14
		s.getTransaction().commit();
15
		s.close();
15
		s.close();
16
		s = openSession();
16
		s = openSession();
17
		s.beginTransaction();
17
		s.beginTransaction();
18
		s.delete( p );
18
		s.delete( p );
19
		s.getTransaction().commit();
19
		s.getTransaction().commit();
20
		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 comparisons68
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements18
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    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
    s.beginTransaction();
    2
    s.beginTransaction();
    3
    Parent p = new Parent("p");
    3
    Parent p = new Parent("p");
    4
    s.save(p);
    4
    s.save(p);
    5
    s.getTransaction().commit();
    5
    s.getTransaction().commit();
    6
    s.close();
    6
    s.close();
    7
    s = openSession();
    7
    s = openSession();
    8
    s.beginTransaction();
    8
    s.beginTransaction();
    9
    p = (Parent)s.load(Parent.class, "p");
    9
    p = (Parent)s.load(Parent.class, "p");
    10
    s.clear();
    10
    s.clear();
    10
    s.evict(p);
    Differences
    Expression1Expression2Difference
    clearevictMETHOD_INVOCATION_NAME_MISMATCH
    s.clear()s.evict(p)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.evict(p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.clear() is a void method call, and thus it cannot be parameterized
    Expression s.evict(p) is a void method call, and thus it cannot be parameterized
    Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.evict(p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.clear() is a void method call, and thus it cannot be parameterized
    Expression s.evict(p) is a void method call, and thus it cannot be parameterized
    10
    s.evict(p);
    11
    s.update(p);
    11
    s.update(p);
    12
    s.getTransaction().commit();
    12
    s.getTransaction().commit();
    13
    s.close();
    13
    s.close();
    14
    s = openSession();
    14
    s = openSession();
    15
    s.beginTransaction();
    15
    s.beginTransaction();
    16
    s.delete(p);
    16
    s.delete(p);
    17
    s.getTransaction().commit();
    17
    s.getTransaction().commit();
    18
    s.close();
    18
    s.close();
    Precondition Violations (8)
    Row Violation
    1Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression s.evict(p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression s.clear() is a void method call, and thus it cannot be parameterized
    4Expression s.evict(p) is a void method call, and thus it cannot be parameterized
    5Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression s.evict(p) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression s.clear() is a void method call, and thus it cannot be parameterized
    8Expression s.evict(p) is a void method call, and thus it cannot be parameterized