Interface Mutiny.SessionFactory

  • All Superinterfaces:
    AutoCloseable
    Enclosing interface:
    Mutiny

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

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

     Mutiny.SessionFactory sessionFactory =
                            createEntityManagerFactory("example")
                                    .unwrap(Mutiny.SessionFactory.class);
     

    Here, configuration properties must be specified in persistence.xml.

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

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