Session s = openSession(); Transaction t = s.beginTransaction(); Point p = new Point( new BigDecimal(1.0), new BigDecimal(1.0) ); s.persist(p); t.commit(); s.clear(); t = s.beginTransaction(); p = (Point) s.createCriteria(Point.class).uniqueResult(); p.setDescription("new desc"); t.commit(); s.clear(); t = s.beginTransaction(); p = (Point) s.createQuery("from Point").uniqueResult(); p.setDescription("new new desc"); t.commit(); s.clear(); t = s.beginTransaction(); p = (Point) s.get(Point.class, p); p.setDescription("new new new desc"); t.commit(); s.close();
Session session = openSession(); Transaction tx = session.beginTransaction(); Person p = new Person("gavin"); p.setEmployeeId("123456"); session.persist(p); tx.commit(); session.close(); session = openSession(); tx = session.beginTransaction(); p = (Person) session.get(Person.class, "gavin"); assertNull( p.getEmployee() ); p.setEmployee( new Employee("123456") ); tx.commit(); session.close(); session = openSession(); tx = session.beginTransaction(); p = (Person) session.get(Person.class, "gavin"); assertTrue( Hibernate.isInitialized( p.getEmployee() ) ); assertNotNull( p.getEmployee() ); session.delete(p); tx.commit(); session.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/rowid/RowIdTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/unconstrained/UnconstrainedTest.java
Method name: void testRowId() Method name: void testUnconstrained()
Number of AST nodes: 21 Number of AST nodes: 22
1
Session s = openSession();
1
Session session = openSession();
2
		Transaction t = s.beginTransaction();
2
		Transaction tx = session.beginTransaction();
3
		Point p = new Point( new BigDecimal(1.0), new BigDecimal(1.0) );
3
		Person p = new P
4
		s
4
erson("gavin");
5
		p.setEmployeeId("123456");
5
.persist(p);
6
		session.persist(p);
6
		t.commit();
7
		tx.commit();
7
		s.clear();
8
		s
8
		
9
		t = s.beginTransaction();
10
		p = (Point) s.createCriteria(Point.class).uniqueResult();
11
		p.setDescription("new desc"
9
ession.close();
10
		
11
		session = openSession();
12
		tx = session.beginTransaction();
13
		p = (Person) session.get(Person.class, "gavin");
14
		assertNull( p.getEmployee() );
12
);
15
		p.setEmployee( new Employee("123456") );
13
		t.commit();
16
		tx.commit();
14
		s.clear();
17
		session.close();
15
		
18
		session = openSession();
16
		t = s.beginTransaction();
19
		tx = session.beginTransaction();
17
		p = (Point) s.createQuery("from Point").uniqueResult();
20
		p = (Person) session.get(Person.class, "gavin")
18
		p.setDescription("new new desc");
19
		t.commit();
20
		s.clear();
21
		
22
		t = s.beginTransaction();
23
		p = (Point) s.get(Point.class, p);
24
		p.setDescription("new new new desc"
21
;
22
		assertTrue( Hibernate.isInitialized( p.getEmployee() ) );
23
		assertNotNull( p.getEmployee() );
25
);
24
		session.delete(p);
26
		t.commit();
25
		tx.commit();
27
		s.close();
26
		session.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 comparisons338
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment8
    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 session = openSession();
    Differences
    Expression1Expression2Difference
    ssessionVARIABLE_NAME_MISMATCH
    1
    Session session = openSession();
    2
    Transaction t = s.beginTransaction();
    2
    Transaction t = s.beginTransaction();
    2
    Transaction tx = session.beginTransaction();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    2
    Transaction tx = session.beginTransaction();
                                                                    
    3
    Person p = new Person("gavin");
    3
    Point p = new Point(new BigDecimal(1.0), new BigDecimal(1.0));
                                                                                                                                
                                                              
    4
    p.setEmployeeId("123456");
    4
    s.persist(p);
    4
    s.persist(p);
    5
    session.persist(p);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.rowid.Pointorg.hibernate.test.unconstrained.PersonVARIABLE_TYPE_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type org.hibernate.test.rowid.Point of variable p does not match with type org.hibernate.test.unconstrained.Person of variable p
    • Make classes org.hibernate.test.rowid.Point and org.hibernate.test.unconstrained.Person extend a common superclass
    5
    session.persist(p);
    5
    t.commit();
    5
    t.commit();
    6
    tx.commit();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    6
    tx.commit();
                                                      
    8
    session = openSession();
    Preondition Violations
    Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    session = openSession();
    6
    s.clear();
    6
    s.clear();
    20
    session.delete(p);
    Differences
    Expression1Expression2Difference
    cleardeleteMETHOD_INVOCATION_NAME_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    s.clear()session.delete(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.clear() is a void method call, and thus it cannot be parameterized
    Expression session.delete(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.clear() is a void method call, and thus it cannot be parameterized
    Expression session.delete(p) is a void method call, and thus it cannot be parameterized
    20
    session.delete(p);
    7
    t = s.beginTransaction();
    7
    t = s.beginTransaction();
    9
    tx = session.beginTransaction();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    9
    tx = session.beginTransaction();
    8
    p = (Point)s.createCriteria(Point.class).uniqueResult();
    8
    p = (Point)s.createCriteria(Point.class).uniqueResult();
    Preondition Violations
    Unmatched statement p=(Point)s.createCriteria(Point.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                      
    9
    p.setDescription("new desc");
                                                                    
                                                                                                    
    10
    p = (Person)session.get(Person.class, "gavin");
    Preondition Violations
    Unmatched statement p=(Person)session.get(Person.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    p = (Person)session.get(Person.class, "gavin");
    10
    t.commit();
    10
    t.commit();
    13
    tx.commit();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    13
    tx.commit();
    11
    s.clear();
    11
    s.clear();
    11
    assertNull(p.getEmployee());
    Differences
    Expression1Expression2Difference
    clearassertNullMETHOD_INVOCATION_NAME_MISMATCH
    s.clear()assertNull(p.getEmployee())ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.clear() 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 assertNull(p.getEmployee()) 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.clear() is a void method call, and thus it cannot be parameterized
    Expression assertNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized
    11
    assertNull(p.getEmployee());
                                                                                        
    12
    p.setEmployee(new Employee("123456"));
    Preondition Violations
    Unmatched statement p.setEmployee(new Employee("123456")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    p.setEmployee(new Employee("123456"));
    12
    t = s.beginTransaction();
    12
    t = s.beginTransaction();
    16
    tx = session.beginTransaction();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    ssessionVARIABLE_NAME_MISMATCH
    16
    tx = session.beginTransaction();
    13
    p = (Point)s.createQuery("from Point").uniqueResult();
                                                                                                                    
                                            
    14
    session.close();
    14
    p.setDescription("new new desc");
                                                                              
                                                        
    15
    session = openSession();
    Preondition Violations
    Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    session = openSession();
                                                                                                    
    17
    p = (Person)session.get(Person.class, "gavin");
    Preondition Violations
    Unmatched statement p=(Person)session.get(Person.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    p = (Person)session.get(Person.class, "gavin");
    15
    t.commit();
    15
    t.commit();
    21
    tx.commit();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    21
    tx.commit();
    16
    s.clear();
    16
    s.clear();
    18
    assertTrue(Hibernate.isInitialized(p.getEmployee()));
    Differences
    Expression1Expression2Difference
    clearassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    s.clear()assertTrue(Hibernate.isInitialized(p.getEmployee()))ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.clear() 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 assertTrue(Hibernate.isInitialized(p.getEmployee())) 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.clear() is a void method call, and thus it cannot be parameterized
    Expression assertTrue(Hibernate.isInitialized(p.getEmployee())) is a void method call, and thus it cannot be parameterized
    18
    assertTrue(Hibernate.isInitialized(p.getEmployee()));
    17
    t = s.beginTransaction();
    17
    t = s.beginTransaction();
    Preondition Violations
    Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                          
    18
    p = (Point)s.get(Point.class, p);
                                                                        
    19
    p.setDescription("new new new desc");
                                                                                      
    20
    t.commit();
    20
    t.commit();
    19
    assertNotNull(p.getEmployee());
    Differences
    Expression1Expression2Difference
    commitassertNotNullMETHOD_INVOCATION_NAME_MISMATCH
    t.commit()assertNotNull(p.getEmployee())ARGUMENT_NUMBER_MISMATCH
    tMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression t.commit() is a void method call, and thus it cannot be parameterized
    Expression assertNotNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized
    Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression t.commit() is a void method call, and thus it cannot be parameterized
    Expression assertNotNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized
    19
    assertNotNull(p.getEmployee());
    21
    s.close();
    21
    s.close();
    7
    session.close();
    Differences
    Expression1Expression2Difference
    ssessionVARIABLE_NAME_MISMATCH
    7
    session.close();
                                            
    22
    session.close();
    Precondition Violations (32)
    Row Violation
    1Type org.hibernate.test.rowid.Point of variable p does not match with type org.hibernate.test.unconstrained.Person of variable p
    2Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression s.clear() is a void method call, and thus it cannot be parameterized
    5Expression session.delete(p) is a void method call, and thus it cannot be parameterized
    6Expression s.clear() 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 session.delete(p) is a void method call, and thus it cannot be parameterized
    9Unmatched statement p=(Point)s.createCriteria(Point.class).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement p=(Person)session.get(Person.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression s.clear() is a void method call, and thus it cannot be parameterized
    13Expression assertNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized
    14Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression s.clear() is a void method call, and thus it cannot be parameterized
    16Expression assertNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized
    17Unmatched statement p.setEmployee(new Employee("123456")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement p=(Person)session.get(Person.class,"gavin"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression s.clear() is a void method call, and thus it cannot be parameterized
    22Expression assertTrue(Hibernate.isInitialized(p.getEmployee())) is a void method call, and thus it cannot be parameterized
    23Expression s.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression s.clear() is a void method call, and thus it cannot be parameterized
    25Expression assertTrue(Hibernate.isInitialized(p.getEmployee())) is a void method call, and thus it cannot be parameterized
    26Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    27Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression t.commit() is a void method call, and thus it cannot be parameterized
    29Expression assertNotNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized
    30Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Expression t.commit() is a void method call, and thus it cannot be parameterized
    32Expression assertNotNull(p.getEmployee()) is a void method call, and thus it cannot be parameterized