I am trying to persist an object that has a many-to-many relationship with other objects already persisted.
Here is my persisted object (they are already persisted i
The exception comes as hibernate trying to persist associated products when you save reservation. Persisting the products is only success if they have no id because id of Product is annotated
@GeneratedValue(strategy=GenerationType.AUTO)
But you got products from repository and ids are not null.
There 2 options to resolve your issue:
(cascade = CascadeType.ALL) on products of Reservation@GeneratedValue(strategy=GenerationType.AUTO) on id of Product