We had the same issue with Hibernate and Spring Web Flow when adding a new child to a list in the parent entity.
There are two easier workarounds, 1) use a Hibernate User Type to override the default PersistentBag implementation of the list. Apply @org.hibernate.annotations.Type(type="org.hibernate.collection.PersistentList") on top of @OneToMany
2) save/merge the parent object instead of the transient child. parent.getChildren().add(0, transientChild); entityManager.merge(parent); // cascade save
Note the funny syntax on the line, parent.getChildren().add(0, transientChild); this is to solve a defect in Hibernate reported here, https://hibernate.onjira.com/browse/HHH-5855.
|