DulcetAirman

OneToMany bidirectional

Feb 23rd, 2017
85
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. em.getTransaction().begin();
  2. Owner owner = new Customer();
  3. Foo f1 = new Order();
  4. Foo f2 = new Order();
  5. List<Foo> foos = new LinkedList<>();
  6. foos.add(f1); foos.add(f2);
  7. owner.setOrders(foos);
  8. em.persist(owner);
  9. em.getTransaction().commit();
RAW Paste Data