Prevent EntityNotFoundException when ID doesn't exist in the DB (#21867)
This makes the behavior consistent with the other store implementations. Closes #21866
This commit is contained in:
parent
82f28f3bae
commit
23f3a1a872
1 changed files with 5 additions and 1 deletions
|
@ -262,7 +262,11 @@ public abstract class JpaMapStorage<RE extends JpaRootEntity, E extends Abstract
|
||||||
UUID uuid = UUIDKey.INSTANCE.fromStringSafe(key);
|
UUID uuid = UUIDKey.INSTANCE.fromStringSafe(key);
|
||||||
if (uuid == null) return false;
|
if (uuid == null) return false;
|
||||||
removeFromCache(key);
|
removeFromCache(key);
|
||||||
em.remove(em.getReference(entityType, uuid));
|
// First find the entity, as just trying to remove it will throw an EntityNotFoundException
|
||||||
|
RE entity = em.find(entityType, uuid);
|
||||||
|
if (entity != null) {
|
||||||
|
em.remove(entity);
|
||||||
|
}
|
||||||
logger.tracef("tx %d: delete entity %s", hashCode(), key);
|
logger.tracef("tx %d: delete entity %s", hashCode(), key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue