Entity version is not updated when the entity is root entity

Closes #17339
This commit is contained in:
vramik 2023-02-28 14:08:04 +01:00 committed by Hynek Mlnařík
parent b4050b9fa8
commit d923aa5d5d

View file

@ -47,7 +47,8 @@ public class JpaEntityVersionListener implements PreInsertEventListener, PreDele
*/
public void updateEntityVersion(Object entity) throws HibernateException {
Object root = entity;
while(root instanceof JpaChildEntity) {
if (root instanceof JpaChildEntity) {
while (root instanceof JpaChildEntity) {
root = ((JpaChildEntity<?>) entity).getParent();
if (root instanceof JpaRootEntity) {
if (!((JpaRootEntity) root).updateEntityVersion()) {
@ -55,6 +56,9 @@ public class JpaEntityVersionListener implements PreInsertEventListener, PreDele
}
}
}
} else if (root instanceof JpaRootEntity) {
((JpaRootEntity) root).updateEntityVersion();
}
}
@Override