OneToOne bidirectional

DulcetAirman Feb 23rd, 2017 (edited) 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand