Session s = openSession(); s.beginTransaction(); Employee e = new Employee(); e.setName( "Steve" ); e.setSex( 'M' ); e.setTitle( "grand poobah" ); s.save( e ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); Customer c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) ); s.getTransaction().commit(); s.close(); assertNull( c ); s = openSession(); s.beginTransaction(); e = ( Employee ) s.get( Employee.class, new Long( e.getId() ) ); c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) ); s.getTransaction().commit(); s.close(); assertNotNull( e ); assertNull( c ); s = openSession(); s.beginTransaction(); s.delete( e ); s.getTransaction().commit(); s.close();
Session s = openSession(); s.beginTransaction(); Employee e = new Employee(); e.setName( "Steve" ); e.setSex( 'M' ); e.setTitle( "grand poobah" ); s.save( e ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); Customer c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) ); s.getTransaction().commit(); s.close(); assertNull( c ); s = openSession(); s.beginTransaction(); e = ( Employee ) s.get( Employee.class, new Long( e.getId() ) ); c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) ); s.getTransaction().commit(); s.close(); assertNotNull( e ); assertNull( c ); s = openSession(); s.beginTransaction(); s.delete( e ); 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/discriminator/DiscriminatorTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java
Method name: void testAccessAsIncorrectSubclass() Method name: void testAccessAsIncorrectSubclass()
Number of AST nodes: 28 Number of AST nodes: 28
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		s.beginTransaction();
3
		Employee e = new Employee();
3
		Employee e = new Employee();
4
		e.setName( "Steve" );
4
		e.setName( "Steve" );
5
		e.setSex( 'M' );
5
		e.setSex( 'M' );
6
		e.setTitle( "grand poobah" );
6
		e.setTitle( "grand poobah" );
7
		s.save( e );
7
		s.save( e );
8
		s.getTransaction().commit();
8
		s.getTransaction().commit();
9
		s.close();
9
		s.close();
10
		s = openSession();
10
		s = openSession();
11
		s.beginTransaction();
11
		s.beginTransaction();
12
		Customer c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) );
12
		Customer c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) );
13
		s.getTransaction().commit();
13
		s.getTransaction().commit();
14
		s.close();
14
		s.close();
15
		assertNull( c );
15
		assertNull( c );
16
		s = openSession();
16
		s = openSession();
17
		s.beginTransaction();
17
		s.beginTransaction();
18
		e = ( Employee ) s.get( Employee.class, new Long( e.getId() ) );
18
		e = ( Employee ) s.get( Employee.class, new Long( e.getId() ) );
19
		c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) );
19
		c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) );
20
		s.getTransaction().commit();
20
		s.getTransaction().commit();
21
		s.close();
21
		s.close();
22
		assertNotNull( e );
22
		assertNotNull( e );
23
		assertNull( c );
23
		assertNull( c );
24
		s = openSession();
24
		s = openSession();
25
		s.beginTransaction();
25
		s.beginTransaction();
26
		s.delete( e );
26
		s.delete( e );
27
		s.getTransaction().commit();
27
		s.getTransaction().commit();
28
		s.close();
28
		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 comparisons140
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements24
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment4
    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
    Employee e = new Employee();
    3
    Employee e = new Employee();
                                                              
    4
    e.setName("Steve");
    4
    e.setName("Steve");
    4
    e.setName("Steve");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.discriminator.Employeeorg.hibernate.test.joinedsubclass.EmployeeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    • Make classes org.hibernate.test.discriminator.Employee and org.hibernate.test.joinedsubclass.Employee extend a common superclass
    4
    e.setName("Steve");
    5
    e.setSex('M');
    5
    e.setSex('M');
    5
    e.setSex('M');
    Differences
    Expression1Expression2Difference
    org.hibernate.test.discriminator.Employeeorg.hibernate.test.joinedsubclass.EmployeeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    • Make classes org.hibernate.test.discriminator.Employee and org.hibernate.test.joinedsubclass.Employee extend a common superclass
    5
    e.setSex('M');
    6
    e.setTitle("grand poobah");
    6
    e.setTitle("grand poobah");
    6
    e.setTitle("grand poobah");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.discriminator.Employeeorg.hibernate.test.joinedsubclass.EmployeeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    • Make classes org.hibernate.test.discriminator.Employee and org.hibernate.test.joinedsubclass.Employee extend a common superclass
    6
    e.setTitle("grand poobah");
    7
    s.save(e);
    7
    s.save(e);
    7
    s.save(e);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.discriminator.Employeeorg.hibernate.test.joinedsubclass.EmployeeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    • Make classes org.hibernate.test.discriminator.Employee and org.hibernate.test.joinedsubclass.Employee extend a common superclass
    7
    s.save(e);
    8
    s.getTransaction().commit();
    8
    s.getTransaction().commit();
    9
    s.close();
    9
    s.close();
    10
    s = openSession();
    10
    s = openSession();
    11
    s.beginTransaction();
    11
    s.beginTransaction();
                                                                                                                                          
    12
    Customer c = (Customer)s.get(Customer.class, new Long(e.getId()));
    Preondition Violations
    Unmatched statement Customer c=(Customer)s.get(Customer.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    Customer c = (Customer)s.get(Customer.class, new Long(e.getId()));
    12
    Customer c = (Customer)s.get(Customer.class, new Long(e.getId()));
    12
    Customer c = (Customer)s.get(Customer.class, new Long(e.getId()));
    Preondition Violations
    Unmatched statement Customer c=(Customer)s.get(Customer.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                          
    13
    s.getTransaction().commit();
    13
    s.getTransaction().commit();
    14
    s.close();
    14
    s.close();
    15
    assertNull(c);
    15
    assertNull(c);
    15
    assertNull(c);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.discriminator.Customerorg.hibernate.test.joinedsubclass.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.discriminator.Customer of variable c does not match with type org.hibernate.test.joinedsubclass.Customer of variable c
    • Make classes org.hibernate.test.discriminator.Customer and org.hibernate.test.joinedsubclass.Customer extend a common superclass
    15
    assertNull(c);
    16
    s = openSession();
    16
    s = openSession();
    17
    s.beginTransaction();
    17
    s.beginTransaction();
                                                                                                                        
    18
    e = (Employee)s.get(Employee.class, new Long(e.getId()));
    Preondition Violations
    Unmatched statement e=(Employee)s.get(Employee.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18
    e = (Employee)s.get(Employee.class, new Long(e.getId()));
    18
    e = (Employee)s.get(Employee.class, new Long(e.getId()));
    18
    e = (Employee)s.get(Employee.class, new Long(e.getId()));
    Preondition Violations
    Unmatched statement e=(Employee)s.get(Employee.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                        
                                                                                                                        
    19
    c = (Customer)s.get(Customer.class, new Long(e.getId()));
    Preondition Violations
    Unmatched statement c=(Customer)s.get(Customer.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19
    c = (Customer)s.get(Customer.class, new Long(e.getId()));
    19
    c = (Customer)s.get(Customer.class, new Long(e.getId()));
    19
    c = (Customer)s.get(Customer.class, new Long(e.getId()));
    Preondition Violations
    Unmatched statement c=(Customer)s.get(Customer.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                        
    20
    s.getTransaction().commit();
    20
    s.getTransaction().commit();
    21
    s.close();
    21
    s.close();
    22
    assertNotNull(e);
    22
    assertNotNull(e);
    22
    assertNotNull(e);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.discriminator.Employeeorg.hibernate.test.joinedsubclass.EmployeeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    • Make classes org.hibernate.test.discriminator.Employee and org.hibernate.test.joinedsubclass.Employee extend a common superclass
    22
    assertNotNull(e);
    23
    assertNull(c);
    23
    assertNull(c);
    23
    assertNull(c);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.discriminator.Customerorg.hibernate.test.joinedsubclass.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.discriminator.Customer of variable c does not match with type org.hibernate.test.joinedsubclass.Customer of variable c
    • Make classes org.hibernate.test.discriminator.Customer and org.hibernate.test.joinedsubclass.Customer extend a common superclass
    23
    assertNull(c);
    24
    s = openSession();
    24
    s = openSession();
    25
    s.beginTransaction();
    25
    s.beginTransaction();
    26
    s.delete(e);
    26
    s.delete(e);
    26
    s.delete(e);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.discriminator.Employeeorg.hibernate.test.joinedsubclass.EmployeeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    • Make classes org.hibernate.test.discriminator.Employee and org.hibernate.test.joinedsubclass.Employee extend a common superclass
    26
    s.delete(e);
    27
    s.getTransaction().commit();
    27
    s.getTransaction().commit();
    28
    s.close();
    28
    s.close();
    Precondition Violations (14)
    Row Violation
    1Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    2Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    3Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    4Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    5Unmatched statement Customer c=(Customer)s.get(Customer.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement Customer c=(Customer)s.get(Customer.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Type org.hibernate.test.discriminator.Customer of variable c does not match with type org.hibernate.test.joinedsubclass.Customer of variable c
    8Unmatched statement e=(Employee)s.get(Employee.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement e=(Employee)s.get(Employee.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement c=(Customer)s.get(Customer.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement c=(Customer)s.get(Customer.class,new Long(e.getId())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e
    13Type org.hibernate.test.discriminator.Customer of variable c does not match with type org.hibernate.test.joinedsubclass.Customer of variable c
    14Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e