Interface Stage.SessionFactory

  • All Superinterfaces:
    AutoCloseable
    Enclosing interface:
    Stage

    public static interface Stage.SessionFactory
    extends AutoCloseable
    Factory for reactive sessions.

    A Stage.SessionFactory may be obtained from an instance of EntityManagerFactory as follows:

     Stage.SessionFactory sessionFactory =
                            createEntityManagerFactory("example")
                                    .unwrap(Stage.SessionFactory.class);
     
    Here, configuration properties must be specified in persistence.xml.

    Alternatively, a Stage.SessionFactory may be obtained via programmatic configuration of Hibernate using:

     Configuration configuration = new Configuration();
     ...
     Stage.SessionFactory sessionFactory =
                    configuration.buildSessionFactory(
                            new ReactiveServiceRegistryBuilder()
                                    .applySettings( configuration.getProperties() )
                                    .build()
                    )
                    .unwrap(Stage.SessionFactory.class);
     
Parameters:
work - a function which accepts the session and returns the result of the work as a CompletionStage.
Parameters:
tenantId - the id of the tenant
work - a function which accepts the session and returns the result of the work as a CompletionStage.