Class JcmsHibernateEventListener

  • All Implemented Interfaces:
    DBConstants, java.io.Serializable, org.hibernate.event.PostDeleteEventListener, org.hibernate.event.PostInsertEventListener, org.hibernate.event.PostUpdateEventListener, org.hibernate.event.PreUpdateEventListener

    public class JcmsHibernateEventListener
    extends java.lang.Object
    implements org.hibernate.event.PreUpdateEventListener, org.hibernate.event.PostInsertEventListener, org.hibernate.event.PostUpdateEventListener, org.hibernate.event.PostDeleteEventListener, DBConstants
    This class is a singleton that dispatches Hibernate events to JCMS DBListeners
    Since:
    jcms-6.0.0
    Author:
    Olivier Dedieu
    See Also:
    Serialized Form
    • Method Detail

      • getInstance

        public static JcmsHibernateEventListener getInstance()
        Returns the singleton.
        Returns:
        the singleton.
        Since:
        jcms-6.0.0
      • addListener

        public void addListener​(DBListener listener)
        Adds a DBListener for all the classes.
        Parameters:
        listener - the listener
        Since:
        jcms-6.0.0
      • addListener

        public void addListener​(DBListener listener,
                                java.lang.Class<?> clazz)
        Adds a DBListener for the given class.
        Parameters:
        listener - the listener
        clazz - the class
        Since:
        jcms-6.0.0
      • removeListener

        public void removeListener​(DBListener listener)
        Removes a DBListener for all the classes.
        Parameters:
        listener - the listener
        Since:
        jcms-6.0.0
      • removeListener

        public void removeListener​(DBListener listener,
                                   java.lang.Class<?> clazz)
        Removes a DBListener for the given class.
        Parameters:
        listener - the listener
        clazz - the class
        Since:
        jcms-6.0.0
      • getDBListenerSet

        public java.util.Set<DBListener> getDBListenerSet()
        Returns an unmodifiable view of the listener set.
        Returns:
        an unmodifiable view of the listener set.
        Since:
        jcms-6.1.0
      • getDBListenerClassMap

        public java.util.Map<java.lang.Class<?>,​java.util.Set<DBListener>> getDBListenerClassMap()
        Returns an unmodifiable view of the Map of class / listener.
        Returns:
        an unmodifiable view of the Map of class / listener.
        Since:
        jcms-6.1.0
      • isClassListen

        public boolean isClassListen​(java.lang.Class<?> clazz)
        Returns true if the given class is explicitly listen by a DBListener.
        Parameters:
        clazz - the class.
        Returns:
        true if the given class is explicitly listen by a DBListener.
        Since:
        jcms-6.1.0
      • onPostInsert

        public void onPostInsert​(org.hibernate.event.PostInsertEvent event)
        Specified by:
        onPostInsert in interface org.hibernate.event.PostInsertEventListener
      • onPostInsert

        public void onPostInsert​(org.hibernate.event.PostInsertEvent event,
                                 boolean firstTime)
      • onPreUpdate

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

        public boolean onPreUpdateInternal​(org.hibernate.event.PreUpdateEvent event)
      • onPostUpdate

        public void onPostUpdate​(org.hibernate.event.PostUpdateEvent event)
        Specified by:
        onPostUpdate in interface org.hibernate.event.PostUpdateEventListener
      • onPostUpdate

        public void onPostUpdate​(org.hibernate.event.PostUpdateEvent event,
                                 boolean firstTime)
      • onPostDelete

        public void onPostDelete​(org.hibernate.event.PostDeleteEvent event)
        Specified by:
        onPostDelete in interface org.hibernate.event.PostDeleteEventListener
      • onPostDelete

        public void onPostDelete​(org.hibernate.event.PostDeleteEvent event,
                                 boolean firstTime)