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 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 140 |
Number of mapped statements | 24 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 4 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
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"); | |||||||||||
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(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e |
2 | Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e |
3 | Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e |
4 | Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e |
5 | 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 |
6 | 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 |
7 | Type org.hibernate.test.discriminator.Customer of variable c does not match with type org.hibernate.test.joinedsubclass.Customer of variable c |
8 | 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 |
9 | 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 |
10 | 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 |
11 | 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 |
12 | Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e |
13 | Type org.hibernate.test.discriminator.Customer of variable c does not match with type org.hibernate.test.joinedsubclass.Customer of variable c |
14 | Type org.hibernate.test.discriminator.Employee of variable e does not match with type org.hibernate.test.joinedsubclass.Employee of variable e |