Top Description Methods
org.hibernate

public Interface SessionBuilder<T extends org.hibernate.SessionBuilder>

Known Direct Subinterfaces
org.hibernate.SharedSessionBuilder, org.hibernate.engine.spi.SessionBuilderImplementor
Known Direct Implementers
org.hibernate.engine.spi.AbstractDelegatingSessionBuilder
Annotations
@SuppressWarnings:UnusedReturnValue
Imports
java.sql.Connection, java.util.TimeZone, org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode, .StatementInspector

Represents a consolidation of all session creation options into a builder style delegate.
Author
Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

this, for method chaining
autoClear
(boolean
Whether the Session should be automatically cleared
autoClear
)

Should the session be automatically cleared on a failed transaction?

public T

Returns:

this, for method chaining
autoClose
(boolean
Should the session be automatically closed
autoClose
)

Deprecated Only integrations can specify autoClosing behavior of individual sessions. See org.hibernate.engine.spi.SessionOwner
Should the session be automatically closed after transaction completion?
public T

Returns:

this, for method chaining
autoJoinTransactions
(boolean
Should JTA transactions be automatically joined
autoJoinTransactions
)

Should the session built automatically join in any ongoing JTA transactions.

public T
clearEventListeners()

Remove all listeners intended for the built Session currently held here, including any auto-apply ones; in other words, start with a clean slate.

public T

Returns:

this, for method chaining
connection
(Connection
The connection to use.
connection
)

Adds a specific connection to the session options.

public T

Returns:

this, for method chaining
connectionHandlingMode
(PhysicalConnectionHandlingMode
The connection handling mode to use.
mode
)

Signifies that the connection release mode from the original session should be used to create the new session.

public T

Returns:

this, for method chaining
connectionReleaseMode
(ConnectionReleaseMode
The connection release mode to use.
connectionReleaseMode
)

Deprecated (since 5.2) use connectionHandlingMode instead
Use a specific connection release mode for these session options.
public T

Returns:

this, for method chaining
eventListeners
(SessionEventListener...
The listeners to incorporate into the built Session
listeners
)

Apply one or more SessionEventListener instances to the listeners for the Session to be built.

public default T

Returns:

this, for method chaining
flushBeforeCompletion
(boolean
Should the session be automatically flushed
flushBeforeCompletion
)

Deprecated (since 5.2) use flushMode(FlushMode) instead.
Should the session be automatically flushed during the "before completion" phase of transaction handling.
public T

Returns:

this, for method chaining
flushMode
(FlushMode
The initial FlushMode to use for the opened Session
flushMode
)

Specify the initial FlushMode to use for the opened Session

public T

Returns:

this, for method chaining
interceptor
(Interceptor
The interceptor to use.
interceptor
)

Adds a specific interceptor to the session options.

public T
public T

Returns:

this, for method chaining
noInterceptor
()

Signifies that no Interceptor should be used.

public Session

Returns:

The session
openSession
()

Deprecated as a consequence of Session being deprecated.
Opens a session with the specified options.
public default T

Returns:

this, for method chaining
setQueryParameterValidation
(boolean
true indicates the validation should be performed, false otherwise

The default value is true

enabled
)

Should org.hibernate.query.Query#setParameter perform parameter validation when the Session is bootstrapped via JPA javax.persistence.EntityManagerFactory

public T

Returns:

this, for method chaining
statementInspector
(StatementInspector
The StatementInspector to use.
statementInspector
)

Applies a specific StatementInspector to the session options.

public T

Returns:

this, for method chaining
tenantIdentifier
(String
The tenant identifier.
tenantIdentifier
)

Define the tenant identifier to be associated with the opened session.

Method Detail

autoClearback to summary
public T autoClear(boolean autoClear)

Should the session be automatically cleared on a failed transaction?

Parameters
autoClear:boolean

Whether the Session should be automatically cleared

Returns:T

this, for method chaining

autoCloseback to summary
public T autoClose(boolean autoClose)

Deprecated

Only integrations can specify autoClosing behavior of individual sessions. See org.hibernate.engine.spi.SessionOwner

Should the session be automatically closed after transaction completion?

Parameters
autoClose:boolean

Should the session be automatically closed

Returns:T

this, for method chaining

Annotations
@Deprecated
See Also
javax.persistence.PersistenceContextType
autoJoinTransactionsback to summary
public T autoJoinTransactions(boolean autoJoinTransactions)

Should the session built automatically join in any ongoing JTA transactions.

Parameters
autoJoinTransactions:boolean

Should JTA transactions be automatically joined

Returns:T

this, for method chaining

See Also
javax.persistence.SynchronizationType#SYNCHRONIZED
clearEventListenersback to summary
public T clearEventListeners()

Remove all listeners intended for the built Session currently held here, including any auto-apply ones; in other words, start with a clean slate. this, for method chaining

connectionback to summary
public T connection(Connection connection)

Adds a specific connection to the session options.

Parameters
connection:Connection

The connection to use.

Returns:T

this, for method chaining

connectionHandlingModeback to summary
public T connectionHandlingMode(PhysicalConnectionHandlingMode mode)

Signifies that the connection release mode from the original session should be used to create the new session.

Parameters
mode:PhysicalConnectionHandlingMode

The connection handling mode to use.

Returns:T

this, for method chaining

connectionReleaseModeback to summary
public T connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode)

Deprecated

(since 5.2) use connectionHandlingMode instead

Use a specific connection release mode for these session options.

Parameters
connectionReleaseMode:ConnectionReleaseMode

The connection release mode to use.

Returns:T

this, for method chaining

Annotations
@Deprecated
eventListenersback to summary
public T eventListeners(SessionEventListener... listeners)

Apply one or more SessionEventListener instances to the listeners for the Session to be built.

Parameters
listeners:SessionEventListener[]

The listeners to incorporate into the built Session

Returns:T

this, for method chaining

flushBeforeCompletionback to summary
public default T flushBeforeCompletion(boolean flushBeforeCompletion)

Deprecated

(since 5.2) use flushMode(FlushMode) instead.

Should the session be automatically flushed during the "before completion" phase of transaction handling.

Parameters
flushBeforeCompletion:boolean

Should the session be automatically flushed

Returns:T

this, for method chaining

Annotations
@Deprecated
@SuppressWarnings:unchecked
flushModeback to summary
public T flushMode(FlushMode flushMode)

Specify the initial FlushMode to use for the opened Session

Parameters
flushMode:FlushMode

The initial FlushMode to use for the opened Session

Returns:T

this, for method chaining

See Also
javax.persistence.PersistenceContextType
interceptorback to summary
public T interceptor(Interceptor interceptor)

Adds a specific interceptor to the session options.

Parameters
interceptor:Interceptor

The interceptor to use.

Returns:T

this, for method chaining

jdbcTimeZoneback to summary
public T jdbcTimeZone(TimeZone timeZone)
noInterceptorback to summary
public T noInterceptor()

Signifies that no Interceptor should be used.

By default the Interceptor associated with the SessionFactory is passed to the Session whenever we open one without the user having specified a specific interceptor to use.

Calling interceptor(Interceptor) with null has the same net effect.

Returns:T

this, for method chaining

openSessionback to summary
public Session openSession()

Deprecated

as a consequence of Session being deprecated. See corresponding docs for further information.

Opens a session with the specified options.

Returns:Session

The session

setQueryParameterValidationback to summary
public default T setQueryParameterValidation(boolean enabled)

Should org.hibernate.query.Query#setParameter perform parameter validation when the Session is bootstrapped via JPA javax.persistence.EntityManagerFactory

Parameters
enabled:boolean

true indicates the validation should be performed, false otherwise

The default value is true

Returns:T

this, for method chaining

statementInspectorback to summary
public T statementInspector(StatementInspector statementInspector)

Applies a specific StatementInspector to the session options.

Parameters
statementInspector:StatementInspector

The StatementInspector to use.

Returns:T

this, for method chaining

tenantIdentifierback to summary
public T tenantIdentifier(String tenantIdentifier)

Define the tenant identifier to be associated with the opened session.

Parameters
tenantIdentifier:String

The tenant identifier.

Returns:T

this, for method chaining