1 | public void testManyToOne() throws Exception {↵ | | 1 | public void testOuterJoin() throws Exception {↵
|
2 | Session s = openSession();↵ | | 2 | Session s = openSession();↵
|
3 | One one = new One();↵ | | 3 | Eye e = new Eye();↵
|
4 | s.save(one);↵ | | 4 | ↵
|
5 | one.setValue("yada");↵ | | 5 | e.setName("Eye Eye");↵
|
6 | Many many = new Many();↵ | | 6 | Jay jay = new Jay(e);↵
|
7 | many.setOne(one);↵ | | 7 | e.setJay(jay);↵
|
8 | s.save(many);↵ | | 8 | s.saveOrUpdate(e);↵
|
9 | s.flush();↵ | | 9 | s.flush();↵
|
10 | s.connection().commit();↵ | | 10 | s.connection().commit();↵
|
11 | s.close();↵ | | 11 | s.close();↵
|
|
12 | s = openSession();↵ | | 12 | s = openSession();↵
|
13 | one = (One) s.load( One.class, one.getKey() );↵ | | 13 | e = (Eye) s.↵
|
14 | one.getManies().size(↵ | | 14 | createCriteria(Eye.class).uniqueResult();↵
|
| | | 15 | assertTrue( Hibernate.isInitialized( e.getJay() ) );↵
|
15 | );↵ | | 16 | assertTrue( Hibernate.isInitialized( e.getJays() ) );↵
|
16 | s.connection().commit();↵ | | 17 | s.connection().commit();↵
|
17 | s.close();↵ | | 18 | s.close();↵
|
|
|
18 | s = openSession();↵ | | 19 | s = openSession();↵
|
19 | many = (Many) s.load( Many.class, many.getKey() );↵ | | 20 | jay = (Jay) s.↵
|
20 | assertTrue( "many-to-one assoc", man↵ | | 21 | createQuery("select new Jay(eye) from Eye eye").uniqueResult();↵
|
21 | y.getOne()!=null );↵ | | 22 | assertTrue( "Eye Eye".equals( jay.getEye().getName() ) );↵
|
22 | s.delete( many.getOne() );↵ | | 23 | s.delete( jay.getEye() );↵
|
23 | s.delete(many);↵ | | 24 | ↵
|
24 | s.flush();↵ | | 25 | s.flush();↵
|
25 | s.connection().commit();↵ | | 26 | s.connection().commit();↵
|
26 | s.close();↵ | | 27 | s.close();↵
|
27 | | | 28 |
|