I have two Entities: Ticket and Party. Ticket has a composition collection of parties that can be referenced using Ticket.parties.
When I attempt to get which parties have been deleted using persistenceTools I keep getting ALL previously deleted parties and not just the one that was deleted as part of the current save. For example, if I delete (soft delete) a party from the ticket and hit save then my logic will detect the deleted party and handle it accordingly. The problem is if I delete another party from the ticket and save again, I get both previously deleted parties instead of just the one I deleted. Why does getOldValue keep on getting me all previously deleted parties? Is there a way for me to check if a party was just deleted and not deleted as part of a previous transaction? All of this occurs in the Ticket listener as all my composition logic is in there. It won’t work for me to use the Party listener.
My code example, I keep getting all previously deleted parties no matter how many times I save.
for (Party p : (Vector<Party>) persistenceTools.getOldValue(ticket, "parties")) {
if (PersistenceHelper.isDeleted(p)) {
// My Code ...
}
}
Thanks.