Spring-Data JPA: save new entity referencing existing one
I had a similar issue where I was trying to save an new entity object with an already saved entity object inside. What I did was implemented Persistable< T > and implemented isNew() accordingly. public class MyEntity implements Persistable<Long> { public boolean isNew() { return null == getId() && subEntity.getId() == null; } Or you … Read more