Class DefaultReactiveLoadEventListener

java.lang.Object
org.hibernate.reactive.event.impl.DefaultReactiveLoadEventListener
All Implemented Interfaces:
Serializable, org.hibernate.event.spi.LoadEventListener, ReactiveLoadEventListener

public class DefaultReactiveLoadEventListener extends Object implements org.hibernate.event.spi.LoadEventListener, ReactiveLoadEventListener
A reactive DefaultLoadEventListener.

Note that sometimes Hibernate ORM calls SessionImpl.internalLoad(String, Object, boolean, boolean) and onLoad(LoadEvent, LoadType) is called. We only support this case when loading generates a proxy.

The return value of the private methods loading the entity is a proxy or a CompletionStage. The CompletionStage only happens when we query the db and a proxy is not created. If onLoad(LoadEvent, LoadType) is called, we cannot get the entity loaded from the db without blocking the request and therefore we aren't going to support this case for now.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.hibernate.event.spi.LoadEventListener

    org.hibernate.event.spi.LoadEventListener.LoadType
  • Field Summary

    Fields inherited from interface org.hibernate.event.spi.LoadEventListener

    GET, IMMEDIATE_LOAD, INTERNAL_LOAD_EAGER, INTERNAL_LOAD_LAZY, INTERNAL_LOAD_NULLABLE, LOAD, RELOAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.hibernate.persister.entity.EntityPersister
    getPersister(org.hibernate.event.spi.LoadEvent event)
     
    loadFromDatasource(org.hibernate.event.spi.LoadEvent event, org.hibernate.persister.entity.EntityPersister persister)
    Performs the process of loading an entity from the configured underlying datasource.
    void
    onLoad(org.hibernate.event.spi.LoadEvent event, org.hibernate.event.spi.LoadEventListener.LoadType loadType)
    This method is not reactive, but we expect it to be called only when a proxy can be returned.
    reactiveOnLoad(org.hibernate.event.spi.LoadEvent event, org.hibernate.event.spi.LoadEventListener.LoadType loadType)
    Handle the given load event.

    Methods inherited from class java.lang.Object

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

    • DefaultReactiveLoadEventListener

      public DefaultReactiveLoadEventListener()
  • Method Details

    • onLoad

      public void onLoad(org.hibernate.event.spi.LoadEvent event, org.hibernate.event.spi.LoadEventListener.LoadType loadType) throws org.hibernate.HibernateException
      This method is not reactive, but we expect it to be called only when a proxy can be returned.

      In particular, it should be called only by SessionImpl.internalLoad(String, Object, boolean, boolean).

      Specified by:
      onLoad in interface org.hibernate.event.spi.LoadEventListener
      Throws:
      UnsupportedOperationException - if the entity loaded is not a proxy
      UnexpectedAccessToTheDatabase - if it needs to load the entity from the db
      org.hibernate.HibernateException
      See Also:
      • DefaultLoadEventListener.onLoad(LoadEvent, LoadType)
    • reactiveOnLoad

      public CompletionStage<Void> reactiveOnLoad(org.hibernate.event.spi.LoadEvent event, org.hibernate.event.spi.LoadEventListener.LoadType loadType) throws org.hibernate.HibernateException
      Handle the given load event.
      Specified by:
      reactiveOnLoad in interface ReactiveLoadEventListener
      Parameters:
      event - The load event to be handled.
      Throws:
      org.hibernate.HibernateException
    • getPersister

      protected org.hibernate.persister.entity.EntityPersister getPersister(org.hibernate.event.spi.LoadEvent event)
    • loadFromDatasource

      protected CompletionStage<Object> loadFromDatasource(org.hibernate.event.spi.LoadEvent event, org.hibernate.persister.entity.EntityPersister persister)
      Performs the process of loading an entity from the configured underlying datasource.
      Parameters:
      event - The load event
      persister - The persister for the entity being requested for load
      Returns:
      The object loaded from the datasource, or null if not found.