Really Nice read
https://newbedev.com/how-to-save-parent-and-child-in-one-shot-jpa-hibernate
- it’s better to use helper method for setting relationships. E.g. class
Cart
should have a method:public void addCartItem(CartItem item){ cartItems.add(item); item.setCart(this); }
Design issues:
- it’s not good to pass DTOs to the DAO layer. It’s better to do the conversion between DTOs and entities even above the service layer.