Product product = new Product();
product.setName("monitor");
em.persist(product);
OrderDetail detail = new OrderDetail(order, product);
order.getOrderDetails().add(detail);
product.getOrderDetails().add(detail);
em.persist(detail);
em.flush();
em.clear();
OrderDetail loaded = em.find(OrderDetail.class, detail.getId());
assertThat(loaded).isNotNull();
assertThat(loaded.getId().getOrder()).isNotNull();
assertThat(loaded.getId().getProduct()).isNotNull();
loaded.setQuantity(12);
em.persist(loaded);
em.flush();
em.clear();
loaded = em.find(OrderDetail.class, detail.getId());
assertThat(loaded).isNotNull();
assertThat(loaded.getId().getOrder()).isNotNull();
assertThat(loaded.getId().getProduct()).isNotNull();
em.remove(loaded);
em.flush();
em.clear();
}