Session s = openSession(); s.beginTransaction(); A a = new A(); a.setData( "Anna" ); s.save( a ); s.getTransaction().commit(); s.close(); // modify detached entity modifyEntity( a ); s = openSession(); s.beginTransaction(); a = ( A ) s.merge( a ); s.getTransaction().commit(); s.close(); verifyModifications( a.getId() );
Session s = openSession(); s.beginTransaction(); Person me = new Person(); me.name = "Steve"; s.save( me ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); me = ( Person ) s.load( Person.class, me.name ); assertNull( me.address ); s.delete( me ); 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/cascade/MultiPathCascadeTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/onetoone/optional/OptionalOneToOneTest.java
Method name: void testMultiPathMergeModifiedDetached() Method name: void testOptionalOneToOneRetrieval()
Number of AST nodes: 14 Number of AST nodes: 14
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		s.beginTransaction();
3
		A a = new A();
3
		Person me = new Person();
4
		a.setData( "Anna" );
4
		me.name = "Steve";
5
		s.save( a );
5
		s.save( me );
6
		s.getTransaction().commit();
6
		s.getTransaction().commit();
7
		s.close();
7
		s.close();
8
		// modify detached entity
9
		modifyEntity( a );
8

10
		s = openSession();
9
		s = openSession();
11
		s.beginTransaction();
10
		s.beginTransaction();
12
		a = ( A ) s.merg
11
		me = ( Person ) s.load( Person.class, me.name );
12
		assertNull( me.address );
13
e( a );
13
		s.delete( me );
14
		s.getTransaction().commit();
14
		s.getTransaction().commit();
15
		s.close();
15
		s.close();
16
		verifyModifications( a.getId() );
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 comparisons65
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    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
    A a = new A();
    3
    A a = new A();
    3
    Person me = new Person();
    Differences
    Expression1Expression2Difference
    ameVARIABLE_NAME_MISMATCH
    3
    Person me = new Person();
                                          
    4
    me.name = "Steve";
    Preondition Violations
    Unmatched statement me.name="Steve"; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    me.name = "Steve";
    4
    a.setData("Anna");
    4
    a.setData("Anna");
    Preondition Violations
    Unmatched statement a.setData("Anna"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                              
    5
    s.save(a);
    5
    s.save(a);
    5
    s.save(me);
    Differences
    Expression1Expression2Difference
    ameVARIABLE_NAME_MISMATCH
    5
    s.save(me);
    6
    s.getTransaction().commit();
    6
    s.getTransaction().commit();
    7
    s.close();
    7
    s.close();
    8
    modifyEntity(a);
    8
    modifyEntity(a);
    12
    s.delete(me);
    Differences
    Expression1Expression2Difference
    modifyEntitydeleteMETHOD_INVOCATION_NAME_MISMATCH
    ameVARIABLE_NAME_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method modifyEntity
    Expression s.delete(me) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    Expression s.delete(me) is a void method call, and thus it cannot be parameterized
    Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method modifyEntity
    Expression s.delete(me) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    Expression s.delete(me) is a void method call, and thus it cannot be parameterized
    12
    s.delete(me);
    9
    s = openSession();
    8
    s = openSession();
    10
    s.beginTransaction();
    9
    s.beginTransaction();
    11
    a = (A)s.merge(a);
    11
    a = (A)s.merge(a);
    10
    me = (Person)s.load(Person.class, me.name);
    Differences
    Expression1Expression2Difference
    ameVARIABLE_NAME_MISMATCH
    mergeloadMETHOD_INVOCATION_NAME_MISMATCH
    s.merge(a)s.load(Person.class,me.name)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s.merge(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.load(Person.class,me.name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.merge(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.load(Person.class,me.name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    me = (Person)s.load(Person.class, me.name);
                                                          
    11
    assertNull(me.address);
    12
    s.getTransaction().commit();
    13
    s.getTransaction().commit();
    13
    s.close();
    14
    s.close();
    14
    verifyModifications(a.getId());
                                                                          
    Precondition Violations (15)
    Row Violation
    1Unmatched statement me.name="Steve"; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement a.setData("Anna"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression s.delete(me) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    6Expression s.delete(me) is a void method call, and thus it cannot be parameterized
    7Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression s.delete(me) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    10Expression s.delete(me) is a void method call, and thus it cannot be parameterized
    11Expression s.merge(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression s.load(Person.class,me.name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression s.merge(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression s.load(Person.class,me.name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Clone fragment #1 returns variable a with type org.hibernate.test.cascade.A , while Clone fragment #2 returns variable me with type org.hibernate.test.onetoone.optional.Person