@Override public void changeAddress(OrderModel order, AddressModel address) { em.getTransaction().begin(); order.setDeliveryAddress(address); em.merge(order); em.getTransaction().commit(); }
@Override public void addOrderEntry(OrderModel order, OrderEntityModel orderEntity) { em.getTransaction().begin(); order.getOrderEntities().add(orderEntity); em.persist(order); em.getTransaction().commit(); }
@Override public void save(OrderModel order, Long addressId) throws Exception { AddressModel address = em.getReference(AddressModel.class, addressId); Assert.assertNotNull(address.getAddress()); Assert.assertNotNull(address.getPhone()); order.setDeliveryAddress(address); em.getTransaction().begin(); em.persist(order); em.getTransaction().commit(); }