1 | try {↵ | | 1 | try {↵
|
2 | s.getTransaction().commit();↵ | | 2 | ↵
|
3 | fail( "expecting TransientObjectException on flush" );↵ | | |
|
4 | }↵ | | |
|
5 | catch( TransientObjectException e ) {↵ | | 3 | // The new membership is transient (it has a null surrogate ID), so↵
|
| | | 4 | // Hibernate assumes that it should be added to the collection.↵
|
| | | 5 | // Inserts are done before deletes, so a ConstraintViolationException↵
|
| | | 6 | // will be thrown on the insert because the unique constraint on the↵
|
6 | // expected result↵ | | 7 | // ↵
|
7 | log.trace( "handled expected exception : " + e );↵ | | |
|
8 | ↵ | | 8 | user and group IDs in the join table is violated. See HHH-2801.↵
|
| | | 9 | s.merge( getUser() );↵
|
| | | 10 | s.getTransaction().commit();↵
|
| | | 11 | fail( "should have failed because inserts are before deletes");↵
|
| | | 12 | }↵
|
| | | 13 | catch( ConstraintViolationException ex ) {↵
|
| | | 14 | // expected↵
|
9 | s.getTransaction().rollback();↵ | | 15 | s.getTransaction().rollback();↵
|
10 | }↵ | | 16 | }↵
|
11 | finally {↵ | | 17 | finally {↵
|
12 | s.close();↵ | | 18 | s.close();↵
|
13 | } | | 19 | }
|