getOldValue returns ALL deleted entities every time

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.

Hi Josh,

I confirm the problem, see getOldValue() for collection attribute returns all soft deleted items · Issue #1037 · cuba-platform/cuba · GitHub
It is caused by the fact that soft deletion is temporarily switched off when merging an entity. We’ll think what we can do. Unfortunately, I don’t see any immediate workaround except making the Party entity hard-deleted.

Thanks. Unfortunately I can’t make Party hard-deleted. I’ll need some sort of solution in the next month or two. Let me know if you come up with a solution and its timeline, else I’ll need to come up with a solution on my own.

Thanks again.

Hi Josh,

We’ll include fix in the platform release 6.9.4.