1 | public void testFilteredJoinedSubclassHqlDeleteNonLeaf() {↵ | | 1 | public void testFilteredJoinedSubclassHqlUpdateRoot() {↵
|
2 | Session s = openSession();↵ | | 2 | Session s = openSession();↵
|
3 | s.beginTransaction();↵ | | 3 | s.beginTransaction();↵
|
4 | s.save( new Employee( "John", 'M', "john", new Date() ) );↵ | | 4 | s.save( new Employee( "John", 'M', "john", new Date() ) );↵
|
5 | s.save( new Employee( "Jane", 'F', "jane", new Date() ) );↵ | | 5 | s.save( new Employee( "Jane", 'F', "jane", new Date() ) );↵
|
6 | s.save( new Customer( "Charlie", 'M', "charlie", "Acme" ) );↵ | | 6 | s.save( new Customer( "Charlie", 'M', "charlie", "Acme" ) );↵
|
7 | s.save( new Customer( "Wanda", 'F', "wanda", "ABC" ) );↵ | | 7 | s.save( new Customer( "Wanda", 'F', "wanda", "ABC" ) );↵
|
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 | s.enableFilter( "sex" ).setParameter( "sexCode", new Character('M' ) );↵ | | 12 | s.enableFilter( "sex" ).setParameter( "sexCode", new Character('M' ) );↵
|
13 | int count = s.createQuery( "delete User" ).executeUpdate();↵ | | 13 | int count = s.createQuery( "update Person p set p.name = '<male>'" ).executeUpdate();↵
|
14 | assertEquals( 2, count );↵ | | 14 | assertEquals( 2, count );↵
|
15 | s.getTransaction().commit();↵ | | 15 | s.getTransaction().commit();↵
|
16 | s.close();↵ | | 16 | s.close();↵
|
|
17 | s = openSession();↵ | | 17 | s = openSession();↵
|
18 | s.beginTransaction();↵ | | 18 | s.beginTransaction();↵
|
19 | s.createQuery( "delete Person" ).executeUpdate();↵ | | 19 | s.createQuery( "delete Person" ).executeUpdate();↵
|
20 | s.getTransaction().commit();↵ | | 20 | s.getTransaction().commit();↵
|
21 | s.close();↵ | | 21 | s.close();↵
|
22 | | | 22 |
|