Package org.hibernate

Interface SessionBuilder

All Superinterfaces:
CommonBuilder
All Known Subinterfaces:
SessionBuilderImplementor, SharedSessionBuilder, SharedSessionBuilderImplementor
All Known Implementing Classes:
AbstractDelegatingSessionBuilder, AbstractDelegatingSessionBuilderImplementor, AbstractDelegatingSharedSessionBuilder

public interface SessionBuilder extends CommonBuilder
Allows creation of a new Session with specific options overriding the defaults from the SessionFactory.
 try (var session =
         sessionFactory.withOptions()
             .tenantIdentifier(tenantId)
             .initialCacheMode(CacheMode.PUT)
             .flushMode(FlushMode.COMMIT)
             .interceptor(new Interceptor() {
                 @Override
                 public void preFlush(Iterator<Object> entities) {
                     ...
                 }
             })
             .openSession()) {
     ...
 }
 
See Also: