1 | public void testMultiPathMergeModifiedDetached() throws Exception↵ | | 1 | public void test↵
|
2 | {↵ | | |
|
3 | // persist a simple A in the database↵ | | |
|
| | | 2 | RemoveThenContains() {
↵
|
4 | Session s = openSession();↵ | | 3 | Session s = openSession();
↵
|
5 | s.beginTransaction();↵ | | 4 | s.beginTransaction();
↵
|
6 | A a = new A();↵ | | 5 | Item item = new Item();
↵
|
7 | a.setData( "Anna" );↵ | | 6 | item.setName( "dummy" );
↵
|
8 | s.save( a );↵ | | 7 | s.persist( item );
↵
|
9 | s.getTransaction().commit();↵ | | 8 | s.getTransaction().commit();
↵
|
10 | s.close();↵ | | 9 | s.close();↵
|
|
11 | // modify detached entity↵ | | |
|
12 | modifyEntity( a );↵ | | |
|
|
| | | 10 |
↵
|
13 | s = openSession();↵ | | 11 | s = openSession();
↵
|
14 | s.beginTransaction();↵ | | 12 | s.beginTransaction();
↵
|
15 | a = ( A ) s.merge( a↵ | | 13 | s.delete( item );↵
|
16 | );↵ | | 14 | boolean contains = s.contains( item );
↵
|
17 | s.getTransaction().commit();↵ | | 15 | s.getTransaction().commit();
↵
|
18 | s.close();↵ | | 16 | s.close();↵
|
|
19 | verifyModifications( a.getId()↵ | | |
|
|
20 | );↵ | | 17 | assertFalse( "expecting removed entity to not be contained", contains );
↵
|
21 | | | 18 |
|