Advertisement
DulcetAirman

OneToOne bidirectional

Feb 23rd, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. em.getTransaction().begin();
  2. Owner owner = new Owner("bla", 42);
  3. int id = owner.getId();
  4. Foo foo = new Foo(true); // you probably just could pass owner here
  5. owner.setFoo(foo);
  6. em.persist(owner);
  7. em.flush();
  8. // owner = em.find(Owner.class, id); // try with and without this line
  9. System.out.println(owner.getFoo().getSomeValue());
  10. System.out.println(owner.getFoo().getOwner().getSomeOtherValue());
  11. em.getTransaction().commit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement