-1

I'm using spring jpa. I have a main entity with an one to many list connection to another entity.

 @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    private List<PendingRoundInfo> pendingRoundInfos;

I would like that when I remove an entity (PendingRoundInfo) from the list and then save the main entity that the removed item will be deleted from the DB automatically without calling repository.delete();

The current result is that the entity is removed from the one to many connection table but still exist on its own.

lior
  • 1,127
  • 3
  • 24
  • 43

1 Answers1

0

When you delete the object, make sure that List<PendingRoundInfo> is still attached to the session, and call entityManager.merge(Parent Object) then entityManager.flush() or commit() based on your transaction configuration.

K139
  • 3,654
  • 13
  • 17