Class JpaEntityVersionListener
- java.lang.Object
-
- org.keycloak.models.map.storage.jpa.hibernate.listeners.JpaEntityVersionListener
-
- All Implemented Interfaces:
Serializable
,org.hibernate.event.spi.PreDeleteEventListener
,org.hibernate.event.spi.PreInsertEventListener
,org.hibernate.event.spi.PreUpdateEventListener
public class JpaEntityVersionListener extends Object implements org.hibernate.event.spi.PreInsertEventListener, org.hibernate.event.spi.PreDeleteEventListener, org.hibernate.event.spi.PreUpdateEventListener
Listen on changes on child- and root entities and updates the current entity version of the root. This support a multiple level parent-child relationship, where all parents needs the entity version to be updated in case it was effectively changed. The traversing is stopped at that point when it is detected that parent entity version is the same one. It is based on an assumption that it may happen that one parent entity could be extracted into "parent A -> parent B -> child" format. Then the change (insertion, deletion or update) of the child should bump the entity version of both parent B and parent A.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static JpaEntityVersionListener
INSTANCE
-
Constructor Summary
Constructors Constructor Description JpaEntityVersionListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
onPreDelete(org.hibernate.event.spi.PreDeleteEvent event)
boolean
onPreInsert(org.hibernate.event.spi.PreInsertEvent event)
boolean
onPreUpdate(org.hibernate.event.spi.PreUpdateEvent event)
void
updateEntityVersion(Object entity)
Traverse from current entity through its parent tree and update the entity version of it.
-
-
-
Field Detail
-
INSTANCE
public static final JpaEntityVersionListener INSTANCE
-
-
Method Detail
-
updateEntityVersion
public void updateEntityVersion(Object entity) throws org.hibernate.HibernateException
Traverse from current entity through its parent tree and update the entity version of it. Stop if non-changed parent is found.- Throws:
org.hibernate.HibernateException
-
onPreInsert
public boolean onPreInsert(org.hibernate.event.spi.PreInsertEvent event)
- Specified by:
onPreInsert
in interfaceorg.hibernate.event.spi.PreInsertEventListener
-
onPreDelete
public boolean onPreDelete(org.hibernate.event.spi.PreDeleteEvent event)
- Specified by:
onPreDelete
in interfaceorg.hibernate.event.spi.PreDeleteEventListener
-
onPreUpdate
public boolean onPreUpdate(org.hibernate.event.spi.PreUpdateEvent event)
- Specified by:
onPreUpdate
in interfaceorg.hibernate.event.spi.PreUpdateEventListener
-
-