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 could use AbstractPersistable and override the isNew there ofcourse.
I don’t know if this will be considered a good way of handling this issue but it worked out quite good for me and besides feels very natural to do.