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 comparisons311
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment13
    Number of unmapped statements in the second code fragment14
    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");
    Preondition Violations
    Unmatched statement Person p=new Person("gavin"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    Person p = new Person("gavin");
    3
    Point p = new Point(new BigDecimal(1.0), new BigDecimal(1.0));
    3
    Point p = new Point(new BigDecimal(1.0), new BigDecimal(1.0));
    Preondition Violations
    Unmatched statement Point p=new Point(new BigDecimal(1.0),new BigDecimal(1.0)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                
    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();
    6
    s.clear();
    6
    s.clear();
    Preondition Violations
    Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                              
    7
    t = s.beginTransaction();
    7
    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
                                                        
    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");
    9
    p.setDescription("new desc");
    4
    p.setEmployeeId("123456");
    Differences
    Expression1Expression2Difference
    "new desc""123456"LITERAL_VALUE_MISMATCH
    setDescriptionsetEmployeeIdMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.test.rowid.Pointorg.hibernate.test.unconstrained.PersonVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression p.setDescription("new desc") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p.setEmployeeId("123456") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p.setDescription("new desc") is a void method call, and thus it cannot be parameterized
    Expression p.setEmployeeId("123456") is a void method call, and thus it cannot be parameterized
    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
    4
    p.setEmployeeId("123456");
                                                      
    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();
                                                                      
    9
    tx = session.beginTransaction();
    Preondition Violations
    Unmatched statement tx=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    tx = session.beginTransaction();
                                                                                                    
    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");
                                                                    
    11
    assertNull(p.getEmployee());
                                                                                        
    12
    p.setEmployee(new Employee("123456"));
    Preondition Violations
    Unmatched statement p.setEmployee(new Employee("123456")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12
    p.setEmployee(new Employee("123456"));
    10
    t.commit();
    10
    t.commit();
    13
    tx.commit();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    13
    tx.commit();
    11
    s.clear();
    11
    s.clear();
    Preondition Violations
    Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
    12
    t = s.beginTransaction();
    12
    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
                                                          
    13
    p = (Point)s.createQuery("from Point").uniqueResult();
    13
    p = (Point)s.createQuery("from Point").uniqueResult();
    Preondition Violations
    Unmatched statement p=(Point)s.createQuery("from Point").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                    
                                            
    14
    session.close();
    14
    p.setDescription("new new desc");
    14
    p.setDescription("new new desc");
    Preondition Violations
    Unmatched statement p.setDescription("new new desc"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                              
                                                        
    15
    session = openSession();
    Preondition Violations
    Unmatched statement session=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    15
    session = openSession();
                                                                        
    16
    tx = session.beginTransaction();
    Preondition Violations
    Unmatched statement tx=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    tx = session.beginTransaction();
                                                                                                    
    17
    p = (Person)session.get(Person.class, "gavin");
                                                                                                                      
    18
    assertTrue(Hibernate.isInitialized(p.getEmployee()));
                                                                          
    19
    assertNotNull(p.getEmployee());
                                                
    20
    session.delete(p);
    15
    t.commit();
    15
    t.commit();
    21
    tx.commit();
    Differences
    Expression1Expression2Difference
    ttxVARIABLE_NAME_MISMATCH
    21
    tx.commit();
    16
    s.clear();
    16
    s.clear();
    Preondition Violations
    Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                
    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);
    18
    p = (Point)s.get(Point.class, p);
    Preondition Violations
    Unmatched statement p=(Point)s.get(Point.class,p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
    19
    p.setDescription("new new new desc");
    19
    p.setDescription("new new new desc");
    Preondition Violations
    Unmatched statement p.setDescription("new new new desc"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                      
    20
    t.commit();
    20
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                  
    21
    s.close();
    21
    s.close();
    7
    session.close();
    Differences
    Expression1Expression2Difference
    ssessionVARIABLE_NAME_MISMATCH
    7
    session.close();
                                            
    22
    session.close();
    Precondition Violations (27)
    Row Violation
    1Unmatched statement Person p=new Person("gavin"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement Point p=new Point(new BigDecimal(1.0),new BigDecimal(1.0)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Type org.hibernate.test.rowid.Point of variable p does not match with type org.hibernate.test.unconstrained.Person of variable p
    4Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched 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
    7Expression p.setDescription("new desc") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression p.setEmployeeId("123456") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression p.setDescription("new desc") is a void method call, and thus it cannot be parameterized
    10Expression p.setEmployeeId("123456") is a void method call, and thus it cannot be parameterized
    11Type org.hibernate.test.rowid.Point of variable p does not match with type org.hibernate.test.unconstrained.Person of variable p
    12Unmatched statement session=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement tx=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched 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
    15Unmatched statement p.setEmployee(new Employee("123456")); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    16Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Unmatched statement p=(Point)s.createQuery("from Point").uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement p.setDescription("new new desc"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement session=openSession(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    21Unmatched statement tx=session.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement s.clear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24Unmatched statement p=(Point)s.get(Point.class,p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25Unmatched statement p.setDescription("new new new desc"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    26Unmatched statement t.commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    27Clone fragment #1 returns variables s, t , while Clone fragment #2 returns variables session, tx