1 | public void testAccessAsIncorrectSubclass() {↵ | | 1 | public void testAccessAsIncorrectSubclass() {↵
|
2 | Session s = openSession();↵ | | 2 | Session s = openSession();↵
|
3 | s.beginTransaction();↵ | | 3 | s.beginTransaction();↵
|
4 | Employee e = new Employee();↵ | | 4 | Employee e = new Employee();↵
|
5 | e.setName( "Steve" );↵ | | 5 | e.setName( "Steve" );↵
|
6 | e.setSex( 'M' );↵ | | 6 | e.setSex( 'M' );↵
|
7 | e.setTitle( "grand poobah" );↵ | | 7 | e.setTitle( "grand poobah" );↵
|
8 | s.save( e );↵ | | 8 | s.save( e );↵
|
9 | s.getTransaction().commit();↵ | | 9 | s.getTransaction().commit();↵
|
10 | s.close();↵ | | 10 | s.close();↵
|
|
11 | s = openSession();↵ | | 11 | s = openSession();↵
|
12 | s.beginTransaction();↵ | | 12 | s.beginTransaction();↵
|
13 | Customer c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) );↵ | | 13 | Customer c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) );↵
|
14 | s.getTransaction().commit();↵ | | 14 | s.getTransaction().commit();↵
|
15 | s.close();↵ | | 15 | s.close();↵
|
16 | assertNull( c );↵ | | 16 | assertNull( c );↵
|
|
17 | s = openSession();↵ | | 17 | s = openSession();↵
|
18 | s.beginTransaction();↵ | | 18 | s.beginTransaction();↵
|
19 | e = ( Employee ) s.get( Employee.class, new Long( e.getId() ) );↵ | | 19 | e = ( Employee ) s.get( Employee.class, new Long( e.getId() ) );↵
|
20 | c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) );↵ | | 20 | c = ( Customer ) s.get( Customer.class, new Long( e.getId() ) );↵
|
21 | s.getTransaction().commit();↵ | | 21 | s.getTransaction().commit();↵
|
22 | s.close();↵ | | 22 | s.close();↵
|
23 | assertNotNull( e );↵ | | 23 | assertNotNull( e );↵
|
24 | assertNull( c );↵ | | 24 | assertNull( c );↵
|
|
25 | s = openSession();↵ | | 25 | s = openSession();↵
|
26 | s.beginTransaction();↵ | | 26 | s.beginTransaction();↵
|
27 | s.delete( e );↵ | | 27 | s.delete( e );↵
|
28 | s.getTransaction().commit();↵ | | 28 | s.getTransaction().commit();↵
|
29 | s.close();↵ | | 29 | s.close();↵
|
30 | | | 30 |
|