--Even if you send the delete method to reposytory with the primary key, it seems that the record is not deleted, and dtl is searched by the hdr search for redisplay.
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "tMitsumoriHdrEntity") @JsonIgnore private List<DtlEntity> dtlEntity;
--On the controller, delete dtlEntity with the delete method of the repository, but it seems to disappear on the screen, but the screen revives after another request, it seems that persistence is not done well
--If it is related, if you delete it directly, the data will remain in the hdr and the deletion will return.
--If only, the dtlEntity still remains in the HdrEntity and will not disappear.
--If you do not add the orphanRemoval = true attribute to oneToMany, even if you delete the related table, it will only be in memory and will not be persisted.
//Detail table @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true, fetch = FetchType.EAGER, mappedBy = "tMitsumoriHdrEntity") @JsonIgnore private List<DtlEntity> dtlEntity;
--When you have an association entity in a list, you have to persist it by clearing the association with the clear method, adding and reinserting it.
A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance
--An error occurs
HdrEntity.getDtlEntity().clear(); HdrEntity.getDtlEntity().addAll(saveDtlList); HdRepository.save(HdrEntity);
--First, clear () the field that contains the list of Entity, --Re-enter the changed list in that field again
HibernateException - A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance
5.2. Database access (JPA edition) 126.96.36.199. Implementation of Entity deletion process https://terasolunaorg.github.io/guideline/public_review/ArchitectureInDetail/DataAccessJpa.html#id38
I searched about JPA http://juzow.hatenablog.com/entry/20121017/1350480972