Class JpaAutoFlushListener

java.lang.Object
org.hibernate.event.internal.AbstractFlushingEventListener
org.hibernate.event.internal.DefaultAutoFlushEventListener
org.keycloak.models.map.storage.jpa.hibernate.listeners.JpaAutoFlushListener
All Implemented Interfaces:
org.hibernate.event.service.spi.JpaBootstrapSensitive, org.hibernate.event.spi.AutoFlushEventListener

public class JpaAutoFlushListener extends org.hibernate.event.internal.DefaultAutoFlushEventListener
Extends Hibernate's DefaultAutoFlushEventListener to always flush queued inserts to allow correct handling of orphans of that entities in the same transactions, and also to clear a session-level query cache.

If they wouldn't be flushed, they won't be orphaned (at least not in Hibernate 5.3.24.Final). This class copies over all functionality of the base class that can't be overwritten via inheritance. This is being tracked as part of keycloak/keycloak#11666.

This also clears the JPA map store query level cache for the JpaMapStorage whenever there is some data written to the database.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onAutoFlush(org.hibernate.event.spi.AutoFlushEvent event)
     

    Methods inherited from class org.hibernate.event.internal.AbstractFlushingEventListener

    flushEverythingToExecutions, getCascadingAction, getContext, logFlushResults, performExecutions, postFlush, postPostFlush, wasJpaBootstrap

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • JpaAutoFlushListener

      public JpaAutoFlushListener()
  • Method Details

    • onAutoFlush

      public void onAutoFlush(org.hibernate.event.spi.AutoFlushEvent event) throws org.hibernate.HibernateException
      Specified by:
      onAutoFlush in interface org.hibernate.event.spi.AutoFlushEventListener
      Overrides:
      onAutoFlush in class org.hibernate.event.internal.DefaultAutoFlushEventListener
      Throws:
      org.hibernate.HibernateException