Here are the examples of the java api org.hibernate.SessionBuilder taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
19
Source : JTASessionOpener.java
with Apache License 2.0
from quarkusio
with Apache License 2.0
from quarkusio
/**
* A delegate for opening a JTA-enabled Hibernate ORM session.
* <p>
* The main purpose of this clreplaced is to cache session options when possible;
* if we didn't care about caching, we could just replace any call to
*/
public clreplaced JTASessionOpener {
public static JTASessionOpener create(SessionFactory sessionFactory) {
final CurrentTenantIdentifierResolver currentTenantIdentifierResolver = sessionFactory.unwrap(SessionFactoryImplementor.clreplaced).getCurrentTenantIdentifierResolver();
if (currentTenantIdentifierResolver == null) {
// No tenant ID resolver: we can cache the options.
return new JTASessionOpener(sessionFactory, createOptions(sessionFactory));
} else {
// There is a tenant ID resolver: we cannot cache the options.
return new JTASessionOpener(sessionFactory, null);
}
}
private static SessionBuilder<?> createOptions(SessionFactory sessionFactory) {
return sessionFactory.withOptions().autoClose(// .owner() is deprecated as well, so it looks like we need to rely on deprecated code...
true).connectionHandlingMode(PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_BEFORE_TRANSACTION_COMPLETION).flushMode(FlushMode.ALWAYS);
}
private final SessionFactory sessionFactory;
private final SessionBuilder<?> cachedOptions;
public JTASessionOpener(SessionFactory sessionFactory, SessionBuilder<?> cachedOptions) {
this.sessionFactory = sessionFactory;
this.cachedOptions = cachedOptions;
}
public Session openSession() {
SessionBuilder<?> options = cachedOptions != null ? cachedOptions : createOptions(sessionFactory);
return options.openSession();
}
}
19
Source : JTASessionOpener.java
with Apache License 2.0
from quarkusio
with Apache License 2.0
from quarkusio
public Session openSession() {
SessionBuilder<?> options = cachedOptions != null ? cachedOptions : createOptions(sessionFactory);
return options.openSession();
}
19
Source : AbstractDelegatingSessionBuilder.java
with GNU General Public License v2.0
from lamsfoundation
with GNU General Public License v2.0
from lamsfoundation
/**
* Base clreplaced for {@link SessionBuilder} implementations that wish to implement only parts of that contract themselves
* while forwarding other method invocations to a delegate instance.
*
* @author Gunnar Morling
* @author Guillaume Smet
*/
public abstract clreplaced AbstractDelegatingSessionBuilder<T extends SessionBuilder> implements SessionBuilder<T> {
private final SessionBuilder delegate;
public AbstractDelegatingSessionBuilder(SessionBuilder delegate) {
this.delegate = delegate;
}
@SuppressWarnings("unchecked")
protected T getThis() {
return (T) this;
}
protected SessionBuilder delegate() {
return delegate;
}
@Override
public Session openSession() {
return delegate.openSession();
}
@Override
public T interceptor(Interceptor interceptor) {
delegate.interceptor(interceptor);
return getThis();
}
@Override
public T noInterceptor() {
delegate.noInterceptor();
return getThis();
}
@Override
public T statementInspector(StatementInspector statementInspector) {
delegate.statementInspector(statementInspector);
return getThis();
}
@Override
public T connection(Connection connection) {
delegate.connection(connection);
return getThis();
}
@SuppressWarnings("deprecation")
@Override
public T connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) {
delegate.connectionReleaseMode(connectionReleaseMode);
return getThis();
}
@Override
public T autoJoinTransactions(boolean autoJoinTransactions) {
delegate.autoJoinTransactions(autoJoinTransactions);
return getThis();
}
@Override
public T autoClose(boolean autoClose) {
delegate.autoClose(autoClose);
return getThis();
}
@SuppressWarnings("deprecation")
@Override
public T flushBeforeCompletion(boolean flushBeforeCompletion) {
delegate.flushBeforeCompletion(flushBeforeCompletion);
return getThis();
}
@Override
public T tenantIdentifier(String tenantIdentifier) {
delegate.tenantIdentifier(tenantIdentifier);
return getThis();
}
@Override
public T eventListeners(SessionEventListener... listeners) {
delegate.eventListeners(listeners);
return getThis();
}
@Override
public T clearEventListeners() {
delegate.clearEventListeners();
return getThis();
}
@Override
public T jdbcTimeZone(TimeZone timeZone) {
delegate.jdbcTimeZone(timeZone);
return getThis();
}
@Override
public T setQueryParameterValidation(boolean enabled) {
delegate.setQueryParameterValidation(enabled);
return getThis();
}
@Override
public T connectionHandlingMode(PhysicalConnectionHandlingMode mode) {
delegate.connectionHandlingMode(mode);
return getThis();
}
@Override
public T autoClear(boolean autoClear) {
delegate.autoClear(autoClear);
return getThis();
}
@Override
public T flushMode(FlushMode flushMode) {
delegate.flushMode(flushMode);
return getThis();
}
}
19
Source : AbstractCurrentSessionContext.java
with GNU General Public License v2.0
from lamsfoundation
with GNU General Public License v2.0
from lamsfoundation
protected SessionBuilder baseSessionBuilder() {
final SessionBuilder builder = factory.withOptions();
final CurrentTenantIdentifierResolver resolver = factory.getCurrentTenantIdentifierResolver();
if (resolver != null) {
builder.tenantIdentifier(resolver.resolveCurrentTenantIdentifier());
}
return builder;
}