Class 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 the upmost parent needs the entity version to be updated.
    See Also:
    Serialized Form
    • Constructor Detail

      • JpaEntityVersionListener

        public JpaEntityVersionListener()
    • Method Detail

      • updateEntityVersion

        public void updateEntityVersion​(Object entity)
                                 throws org.hibernate.HibernateException
        Traverse from current entity up to the upmost parent, then update the entity version if it is a root entity.
        Throws:
        org.hibernate.HibernateException
      • onPreInsert

        public boolean onPreInsert​(org.hibernate.event.spi.PreInsertEvent event)
        Specified by:
        onPreInsert in interface org.hibernate.event.spi.PreInsertEventListener
      • onPreDelete

        public boolean onPreDelete​(org.hibernate.event.spi.PreDeleteEvent event)
        Specified by:
        onPreDelete in interface org.hibernate.event.spi.PreDeleteEventListener
      • onPreUpdate

        public boolean onPreUpdate​(org.hibernate.event.spi.PreUpdateEvent event)
        Specified by:
        onPreUpdate in interface org.hibernate.event.spi.PreUpdateEventListener