Session s = openSession(); s.beginTransaction(); A a = new A(); a.setData( "Anna" ); s.save( a ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); // retrieve the previously saved instance from the database, and update it a = ( A ) s.get( A.class, new Long( a.getId() ) ); modifyEntity( a ); s.getTransaction().commit(); s.close(); verifyModifications( a.getId() );
Session s = openSession(); Foo foo = new Foo(); s.save(foo); s.flush(); s.connection().commit(); s.close(); s = openSession(); Foo foo2 = new Foo(); s.load( foo2, foo.getKey() ); // There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15 assertTrue( "create", foo.equalsFoo(foo2) ); s.delete(foo2); 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/cascade/MultiPathCascadeTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
Method name: void testMultiPathGetAndModify() Method name: void testCreate()
Number of AST nodes: 14 Number of AST nodes: 14
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		
3
		A a = new A();
3
Foo foo = new Foo();
4
		a.setData( "Anna" );
4
		s.s
5
		s.save( a );
6
		s.getTransa
5
ave(foo);
6
		s.flush();
7
ction().commit();
7
		s.connection().commit();
8
		s.close();
8
		s.close();
9
		s = openSession();
9
		s = openSession();
10
		s.beginTransaction();
10
		
11
		// retrieve the previously saved instance from the database, and update it
12
		a = ( A ) s.get( A.class, new Long( a.getId() ) );
13
		modifyEntity( a );
14
		s.getTransaction().commit();
15
		s.close();
16
		verifyModifications( a.getId() 
11
Foo foo2 = new Foo();
12
		s.load( foo2, foo.getKey() );
13
		// There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15
14
		assertTrue( "create", foo.equalsFoo(foo2) );
15
		s.delete(foo2);
16
		s.flush();
17
		s.connection().commit();
17
);
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 comparisons148
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment6
    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
    Foo foo = new Foo();
    2
    s.beginTransaction();
                                                    
    3
    A a = new A();
                                  
    4
    a.setData("Anna");
    4
    a.setData("Anna");
    10
    assertTrue("create", foo.equalsFoo(foo2));
    Differences
    Expression1Expression2Difference
    setDataassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    a.setData("Anna")assertTrue("create",foo.equalsFoo(foo2))ARGUMENT_NUMBER_MISMATCH
    aMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression a.setData("Anna") is a void method call, and thus it cannot be parameterized
    Expression assertTrue("create",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    Expression a.setData("Anna") is a void method call, and thus it cannot be parameterized
    Expression assertTrue("create",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    10
    assertTrue("create", foo.equalsFoo(foo2));
    5
    s.save(a);
    5
    s.save(a);
    3
    s.save(foo);
    Differences
    Expression1Expression2Difference
    afooVARIABLE_NAME_MISMATCH
    org.hibernate.test.cascade.Aorg.hibernate.test.legacy.FooVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.cascade.A of variable a does not match with type org.hibernate.test.legacy.Foo of variable foo
    • Make classes org.hibernate.test.cascade.A and org.hibernate.test.legacy.Foo extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    3
    s.save(foo);
                              
    4
    s.flush();
    6
    s.getTransaction().commit();
    6
    s.getTransaction().commit();
    5
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    5
    s.connection().commit();
    7
    s.close();
    7
    s.close();
    6
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    6
    s.close();
                                          
    7
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    s = openSession();
                                                
    8
    Foo foo2 = new Foo();
    8
    s = openSession();
    8
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                          
    9
    s.beginTransaction();
                                                    
    10
    a = (A)s.get(A.class, new Long(a.getId()));
    10
    a = (A)s.get(A.class, new Long(a.getId()));
    Preondition Violations
    Unmatched statement a=(A)s.get(A.class,new Long(a.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                            
    11
    modifyEntity(a);
    11
    modifyEntity(a);
    9
    s.load(foo2, foo.getKey());
    Differences
    Expression1Expression2Difference
    modifyEntityloadMETHOD_INVOCATION_NAME_MISMATCH
    modifyEntity(a)s.load(foo2,foo.getKey())ARGUMENT_NUMBER_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 modifyEntity(a) is a void method call, and thus it cannot be parameterized
    Expression s.load(foo2,foo.getKey()) 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 modifyEntity(a) is a void method call, and thus it cannot be parameterized
    Expression s.load(foo2,foo.getKey()) is a void method call, and thus it cannot be parameterized
    9
    s.load(foo2, foo.getKey());
                                          
    11
    s.delete(foo2);
    12
    s.getTransaction().commit();
    12
    s.getTransaction().commit();
    13
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    13
    s.connection().commit();
    13
    s.close();
    13
    s.close();
    14
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    14
    s.close();
    14
    verifyModifications(a.getId());
    14
    verifyModifications(a.getId());
    12
    s.flush();
    Differences
    Expression1Expression2Difference
    verifyModificationsflushMETHOD_INVOCATION_NAME_MISMATCH
    verifyModifications(a.getId())s.flush()ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized
    Expression s.flush() is a void method call, and thus it cannot be parameterized
    12
    s.flush();
    Precondition Violations (25)
    Row Violation
    1Expression a.setData("Anna") is a void method call, and thus it cannot be parameterized
    2Expression assertTrue("create",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    3Expression a.setData("Anna") is a void method call, and thus it cannot be parameterized
    4Expression assertTrue("create",foo.equalsFoo(foo2)) is a void method call, and thus it cannot be parameterized
    5Type org.hibernate.test.cascade.A of variable a does not match with type org.hibernate.test.legacy.Foo of variable foo
    6Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    7Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    8Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    9Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    10Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement a=(A)s.get(A.class,new Long(a.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    15Expression s.load(foo2,foo.getKey()) is a void method call, and thus it cannot be parameterized
    16Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    18Expression s.load(foo2,foo.getKey()) is a void method call, and thus it cannot be parameterized
    19Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    20Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    21Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    22Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized
    23Expression s.flush() is a void method call, and thus it cannot be parameterized
    24Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized
    25Expression s.flush() is a void method call, and thus it cannot be parameterized