HHH-10664 - Prep 6.0 feature branch - merge hibernate-entitymanager into hibernate-core (continued fixing of hibernate-core test failures)
This commit is contained in:
parent
34b439223e
commit
76bac3268a
|
@ -424,7 +424,8 @@ Should we prefer using the `org.hibernate.engine.transaction.jta.platform.spi.Jt
|
|||
|`hibernate.transaction.auto_close_session` |`true` or `false` (default value) |Causes the session to be closed during the after completion phase of the transaction. If possible, use built-in and automatic session context management instead.
|
||||
|`hibernate.transaction.coordinator_class` | a|
|
||||
|
||||
Names the implementation of `org.hibernate.resource.transaction.TransactionCoordinatorBuilder` to use for creating `org.hibernate.resource.transaction.TransactionCoordinator` instances.
|
||||
Names the implementation of `org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder` to use for creating
|
||||
`org.hibernate.resource.transaction.spi.TransactionCoordinator` instances.
|
||||
|
||||
Can be
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ This documentation largely treats the physical and logic notions of a transactio
|
|||
Hibernate uses the JDBC API for persistence. In the world of Java there are two well-defined mechanism for dealing with transactions in JDBC: JDBC itself and JTA.
|
||||
Hibernate supports both mechanisms for integrating with transactions and allowing applications to manage physical transactions.
|
||||
|
||||
Transaction handling per `Session` is handled by the `org.hibernate.resource.transaction.TransactionCoordinator` contract, which are built by the `org.hibernate.resource.transaction.TransactionCoordinatorBuilder` service.
|
||||
Transaction handling per `Session` is handled by the `org.hibernate.resource.transaction.spi.TransactionCoordinator` contract,
|
||||
which are built by the `org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder` service.
|
||||
`TransactionCoordinatorBuilder` represents a strategy for dealing with transactions whereas TransactionCoordinator represents one instance of that strategy related to a Session.
|
||||
Which `TransactionCoordinatorBuilder` implementation to use is defined by the `hibernate.transaction.coordinator_class` setting.
|
||||
|
||||
|
|
|
@ -444,9 +444,9 @@
|
|||
<section>
|
||||
<title>TransactionCoordinatorBuilder</title>
|
||||
<para>
|
||||
<interfacename>org.hibernate.resource.transaction.TransactionCoordinatorBuilder</interfacename>
|
||||
<interfacename>org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder</interfacename>
|
||||
is used by Hibernate to integrate with and underlying transaction system. It is responsible for
|
||||
building <interfacename>org.hibernate.resource.transaction.TransactionCoordinator</interfacename>
|
||||
building <interfacename>org.hibernate.resource.transaction.spi.TransactionCoordinator</interfacename>
|
||||
instances for use by each Hibernate Session.
|
||||
</para>
|
||||
</section>
|
||||
|
|
|
@ -410,8 +410,8 @@
|
|||
<title>Transaction configuration</title>
|
||||
|
||||
<para>
|
||||
Transaction handling per Session is handled by the <interfacename>org.hibernate.resource.transaction.TransactionCoordinator</interfacename>
|
||||
contract, which are built by the <interfacename>org.hibernate.resource.transaction.TransactionCoordinatorBuilder</interfacename>
|
||||
Transaction handling per Session is handled by the <interfacename>org.hibernate.resource.transaction.spi.TransactionCoordinator</interfacename>
|
||||
contract, which are built by the <interfacename>org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder</interfacename>
|
||||
service. TransactionCoordinatorBuilder represents a strategy for dealing with transactions whereas
|
||||
TransactionCoordinator represents one instance of that strategy related to a Session. Which
|
||||
TransactionCoordinatorBuilder implementation to use is defined by the <literal>hibernate.transaction.coordinator_class</literal>
|
||||
|
|
|
@ -52,8 +52,8 @@
|
|||
|
||||
<para>
|
||||
Transaction handling per Session is handled by the
|
||||
<interfacename>org.hibernate.resource.transaction.TransactionCoordinator</interfacename> contract, which
|
||||
are built by the <interfacename>org.hibernate.resource.transaction.TransactionCoordinatorBuilder</interfacename>
|
||||
<interfacename>org.hibernate.resource.transaction.spi.TransactionCoordinator</interfacename> contract, which
|
||||
are built by the <interfacename>org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder</interfacename>
|
||||
service. TransactionCoordinatorBuilder represents a strategy for dealing with transactions whereas
|
||||
TransactionCoordinator represents one instance of that strategy related to a Session. Which
|
||||
TransactionCoordinatorBuilder implementation to use is defined by the
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
/**
|
||||
* Indicates the manner in which JDBC Connections should be acquired. Inverse to
|
||||
* {@link org.hibernate.ConnectionReleaseMode}.
|
||||
|
@ -32,4 +34,21 @@ public enum ConnectionAcquisitionMode {
|
|||
|
||||
return AS_NEEDED;
|
||||
}
|
||||
|
||||
public static ConnectionAcquisitionMode interpret(Object setting) {
|
||||
if ( setting == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( setting instanceof ConnectionAcquisitionMode ) {
|
||||
return (ConnectionAcquisitionMode) setting;
|
||||
}
|
||||
|
||||
final String value = setting.toString();
|
||||
if ( StringHelper.isEmpty( value ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return interpret( value );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
/**
|
||||
* Defines the various policies by which Hibernate might release its underlying
|
||||
* JDBC connection. Inverse of {@link ConnectionAcquisitionMode}.
|
||||
|
@ -48,4 +50,26 @@ public enum ConnectionReleaseMode{
|
|||
public static ConnectionReleaseMode parse(final String name) {
|
||||
return ConnectionReleaseMode.valueOf( name.toUpperCase(Locale.ROOT) );
|
||||
}
|
||||
|
||||
public static ConnectionReleaseMode interpret(Object setting) {
|
||||
if ( setting == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( setting instanceof ConnectionReleaseMode ) {
|
||||
return (ConnectionReleaseMode) setting;
|
||||
}
|
||||
|
||||
final String value = setting.toString();
|
||||
if ( StringHelper.isEmpty( value ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// here we disregard "auto"
|
||||
if ( value.equalsIgnoreCase( "auto" ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return parse( value );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
|
@ -92,30 +91,62 @@ public interface SessionBuilder<T extends SessionBuilder> {
|
|||
* @param autoJoinTransactions Should JTA transactions be automatically joined
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @see javax.persistence.SynchronizationType#SYNCHRONIZED
|
||||
*/
|
||||
T autoJoinTransactions(boolean autoJoinTransactions);
|
||||
|
||||
/**
|
||||
* Should the session be automatically closed afterQuery transaction completion.
|
||||
* Should the session be automatically closed after transaction completion?
|
||||
*
|
||||
* @param autoClose Should the session be automatically closed
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated Only integrations can specify autoClosing behavior of individual sessions. See
|
||||
* {@link org.hibernate.engine.spi.SessionOwner}
|
||||
* @see javax.persistence.PersistenceContextType
|
||||
*/
|
||||
@Deprecated
|
||||
T autoClose(boolean autoClose);
|
||||
|
||||
/**
|
||||
* Should the session be automatically cleared on a failed transaction?
|
||||
*
|
||||
* @param autoClear Whether the Session should be automatically cleared
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
T autoClear(boolean autoClear);
|
||||
|
||||
/**
|
||||
* Specify the initial FlushMode to use for the opened Session
|
||||
*
|
||||
* @param flushMode The initial FlushMode to use for the opened Session
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @see javax.persistence.PersistenceContextType
|
||||
*/
|
||||
T flushMode(FlushMode flushMode);
|
||||
|
||||
/**
|
||||
* Should the session be automatically flushed during the "beforeQuery completion" phase of transaction handling.
|
||||
*
|
||||
* @param flushBeforeCompletion Should the session be automatically flushed
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated (since 5.2) use {@link #flushMode(FlushMode)} instead.
|
||||
*/
|
||||
T flushBeforeCompletion(boolean flushBeforeCompletion);
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
default T flushBeforeCompletion(boolean flushBeforeCompletion) {
|
||||
if ( flushBeforeCompletion ) {
|
||||
flushMode( FlushMode.ALWAYS );
|
||||
}
|
||||
else {
|
||||
flushMode( FlushMode.MANUAL );
|
||||
}
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the tenant identifier to be associated with the opened session.
|
||||
|
@ -143,6 +174,4 @@ public interface SessionBuilder<T extends SessionBuilder> {
|
|||
*/
|
||||
T clearEventListeners();
|
||||
|
||||
T persistenceUnitTransactionType(PersistenceUnitTransactionType persistenceUnitTransactionType);
|
||||
|
||||
}
|
||||
|
|
|
@ -63,21 +63,31 @@ public interface SharedSessionBuilder<T extends SharedSessionBuilder> extends Se
|
|||
*/
|
||||
T autoJoinTransactions();
|
||||
|
||||
/**
|
||||
* Signifies that the FlushMode from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
T flushMode();
|
||||
|
||||
/**
|
||||
* Signifies that the autoClose flag from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated For same reasons as {@link SessionBuilder#autoClose(boolean)} was deprecated. However, shared
|
||||
* session builders can use {@link #autoClose(boolean)} since they do not "inherit" the owner.
|
||||
*/
|
||||
@Deprecated
|
||||
T autoClose();
|
||||
|
||||
/**
|
||||
* Signifies that the flushBeforeCompletion flag from the original session should be used to create the new session.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated (since 5.2) use {@link #flushMode()} instead.
|
||||
*/
|
||||
T flushBeforeCompletion();
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
default T flushBeforeCompletion() {
|
||||
flushMode();
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,12 +46,13 @@ import org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData;
|
|||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.loader.BatchFetchStyle;
|
||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
import org.hibernate.tuple.entity.EntityTuplizerFactory;
|
||||
|
@ -66,6 +67,7 @@ import static org.hibernate.cfg.AvailableSettings.BATCH_FETCH_STYLE;
|
|||
import static org.hibernate.cfg.AvailableSettings.BATCH_VERSIONED_DATA;
|
||||
import static org.hibernate.cfg.AvailableSettings.CACHE_REGION_PREFIX;
|
||||
import static org.hibernate.cfg.AvailableSettings.CHECK_NULLABILITY;
|
||||
import static org.hibernate.cfg.AvailableSettings.CONNECTION_HANDLING;
|
||||
import static org.hibernate.cfg.AvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY;
|
||||
import static org.hibernate.cfg.AvailableSettings.DEFAULT_BATCH_FETCH_SIZE;
|
||||
import static org.hibernate.cfg.AvailableSettings.DEFAULT_ENTITY_MODE;
|
||||
|
@ -587,7 +589,7 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
true
|
||||
);
|
||||
|
||||
this.flushBeforeCompletionEnabled = cfgService.getSetting( FLUSH_BEFORE_COMPLETION, BOOLEAN, false );
|
||||
this.flushBeforeCompletionEnabled = cfgService.getSetting( FLUSH_BEFORE_COMPLETION, BOOLEAN, true );
|
||||
this.autoCloseSessionEnabled = cfgService.getSetting( AUTO_CLOSE_SESSION, BOOLEAN, false );
|
||||
|
||||
this.statisticsEnabled = cfgService.getSetting( GENERATE_STATISTICS, BOOLEAN, false );
|
||||
|
@ -730,36 +732,73 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
);
|
||||
this.jdbcFetchSize = ConfigurationHelper.getInteger( STATEMENT_FETCH_SIZE, configurationSettings );
|
||||
|
||||
final ConnectionAcquisitionMode connectionAcquisitionMode = ConnectionAcquisitionMode.interpret(
|
||||
ConfigurationHelper.getString(
|
||||
ACQUIRE_CONNECTIONS,
|
||||
configurationSettings,
|
||||
ConnectionAcquisitionMode.AS_NEEDED.name()
|
||||
)
|
||||
);
|
||||
|
||||
final ConnectionReleaseMode connectionReleaseMode;
|
||||
final String releaseModeName = ConfigurationHelper.getString( RELEASE_CONNECTIONS, configurationSettings, "auto" );
|
||||
if ( "auto".equals( releaseModeName ) ) {
|
||||
// nothing was specified (or someone happened to configure the "magic" value)
|
||||
if ( connectionAcquisitionMode == ConnectionAcquisitionMode.IMMEDIATELY ) {
|
||||
connectionReleaseMode = ConnectionReleaseMode.ON_CLOSE;
|
||||
}
|
||||
else {
|
||||
connectionReleaseMode = serviceRegistry.getService( TransactionCoordinatorBuilder.class )
|
||||
.getDefaultConnectionReleaseMode();
|
||||
}
|
||||
}
|
||||
else {
|
||||
connectionReleaseMode = ConnectionReleaseMode.parse( releaseModeName );
|
||||
}
|
||||
this.connectionHandlingMode = PhysicalConnectionHandlingMode.interpret( connectionAcquisitionMode, connectionReleaseMode );
|
||||
this.connectionHandlingMode = interpretConnectionHandlingMode( configurationSettings, serviceRegistry );
|
||||
|
||||
this.commentsEnabled = ConfigurationHelper.getBoolean( USE_SQL_COMMENTS, configurationSettings );
|
||||
|
||||
this.preferUserTransaction = ConfigurationHelper.getBoolean( PREFER_USER_TRANSACTION, configurationSettings, false );
|
||||
}
|
||||
|
||||
private PhysicalConnectionHandlingMode interpretConnectionHandlingMode(
|
||||
Map configurationSettings,
|
||||
StandardServiceRegistry serviceRegistry) {
|
||||
final PhysicalConnectionHandlingMode specifiedHandlingMode = PhysicalConnectionHandlingMode.interpret(
|
||||
configurationSettings.get( CONNECTION_HANDLING )
|
||||
);
|
||||
|
||||
if ( specifiedHandlingMode != null ) {
|
||||
return specifiedHandlingMode;
|
||||
}
|
||||
|
||||
|
||||
final TransactionCoordinatorBuilder transactionCoordinatorBuilder = serviceRegistry.getService( TransactionCoordinatorBuilder.class );
|
||||
|
||||
// see if the deprecated ConnectionAcquisitionMode/ConnectionReleaseMode were used..
|
||||
final ConnectionAcquisitionMode specifiedAcquisitionMode = ConnectionAcquisitionMode.interpret(
|
||||
configurationSettings.get( ACQUIRE_CONNECTIONS )
|
||||
);
|
||||
final ConnectionReleaseMode specifiedReleaseMode = ConnectionReleaseMode.interpret(
|
||||
configurationSettings.get( RELEASE_CONNECTIONS )
|
||||
);
|
||||
if ( specifiedAcquisitionMode != null || specifiedReleaseMode != null ) {
|
||||
return interpretConnectionHandlingMode( specifiedAcquisitionMode, specifiedReleaseMode, configurationSettings, transactionCoordinatorBuilder );
|
||||
}
|
||||
|
||||
return transactionCoordinatorBuilder.getDefaultConnectionHandlingMode();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private PhysicalConnectionHandlingMode interpretConnectionHandlingMode(
|
||||
ConnectionAcquisitionMode specifiedAcquisitionMode,
|
||||
ConnectionReleaseMode specifiedReleaseMode,
|
||||
Map configurationSettings,
|
||||
TransactionCoordinatorBuilder transactionCoordinatorBuilder) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.logUseOfDeprecatedConnectionHandlingSettings();
|
||||
|
||||
final ConnectionAcquisitionMode effectiveAcquisitionMode = specifiedAcquisitionMode == null
|
||||
? ConnectionAcquisitionMode.AS_NEEDED
|
||||
: specifiedAcquisitionMode;
|
||||
|
||||
final ConnectionReleaseMode effectiveReleaseMode;
|
||||
if ( specifiedReleaseMode == null ) {
|
||||
// check the actual setting. If we get in here it *should* be "auto" or null
|
||||
final String releaseModeName = ConfigurationHelper.getString( RELEASE_CONNECTIONS, configurationSettings, "auto" );
|
||||
assert "auto".equalsIgnoreCase( releaseModeName );
|
||||
// nothing was specified (or someone happened to configure the "magic" value)
|
||||
if ( effectiveAcquisitionMode == ConnectionAcquisitionMode.IMMEDIATELY ) {
|
||||
effectiveReleaseMode = ConnectionReleaseMode.ON_CLOSE;
|
||||
}
|
||||
else {
|
||||
effectiveReleaseMode = transactionCoordinatorBuilder.getDefaultConnectionReleaseMode();
|
||||
}
|
||||
}
|
||||
else {
|
||||
effectiveReleaseMode = specifiedReleaseMode;
|
||||
}
|
||||
|
||||
return PhysicalConnectionHandlingMode.interpret( effectiveAcquisitionMode, effectiveReleaseMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardServiceRegistry getServiceRegistry() {
|
||||
return serviceRegistry;
|
||||
|
|
|
@ -86,9 +86,9 @@ import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
|||
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
||||
import org.hibernate.hql.spi.id.local.LocalTemporaryTableBulkIdStrategy;
|
||||
import org.hibernate.hql.spi.id.persistent.PersistentTableBulkIdStrategy;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.cfg;
|
|||
|
||||
import org.hibernate.boot.MetadataBuilder;
|
||||
import org.hibernate.query.internal.ParameterMetadataImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.tool.schema.SourceType;
|
||||
|
||||
/**
|
||||
|
@ -357,8 +359,8 @@ public interface AvailableSettings {
|
|||
String SCHEMA_MANAGEMENT_TOOL = "hibernate.schema_management_tool";
|
||||
|
||||
/**
|
||||
* Names the implementation of {@link org.hibernate.resource.transaction.TransactionCoordinatorBuilder} to use for
|
||||
* creating {@link org.hibernate.resource.transaction.TransactionCoordinator} instances.
|
||||
* Names the implementation of {@link TransactionCoordinatorBuilder} to use for
|
||||
* creating {@link TransactionCoordinator} instances.
|
||||
* <p/>
|
||||
* Can be<ul>
|
||||
* <li>TransactionCoordinatorBuilder instance</li>
|
||||
|
@ -706,7 +708,10 @@ public interface AvailableSettings {
|
|||
* @see org.hibernate.ConnectionAcquisitionMode
|
||||
*
|
||||
* @since 5.1
|
||||
*
|
||||
* @deprecated (since 5.2) use {@link #CONNECTION_HANDLING} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String ACQUIRE_CONNECTIONS = "hibernate.connection.acquisition_mode";
|
||||
|
||||
/**
|
||||
|
@ -714,9 +719,22 @@ public interface AvailableSettings {
|
|||
* this or {@link #ACQUIRE_CONNECTIONS}, not both
|
||||
*
|
||||
* @see org.hibernate.ConnectionReleaseMode
|
||||
*
|
||||
* @deprecated (since 5.2) use {@link #CONNECTION_HANDLING} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String RELEASE_CONNECTIONS = "hibernate.connection.release_mode";
|
||||
|
||||
/**
|
||||
* Specifies how Hibernate should manage JDBC connections in terms of acquiring and releasing.
|
||||
* Supersedes {@link #ACQUIRE_CONNECTIONS} and {@link #RELEASE_CONNECTIONS}
|
||||
*
|
||||
* @see org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
String CONNECTION_HANDLING = "hibernate.connection.handling_mode";
|
||||
|
||||
/**
|
||||
* Context scoping impl for {@link org.hibernate.SessionFactory#getCurrentSession()} processing.
|
||||
*/
|
||||
|
|
|
@ -484,6 +484,7 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
|||
*
|
||||
* @throws IOException Trouble accessing the stream
|
||||
*/
|
||||
@Override
|
||||
public void serialize(ObjectOutputStream oos) throws IOException {
|
||||
if ( ! isReadyForSerialization() ) {
|
||||
throw new HibernateException( "Cannot serialize Session while connected" );
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.engine.jdbc.spi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
|
@ -190,4 +192,7 @@ public interface JdbcCoordinator extends Serializable, TransactionCoordinatorOwn
|
|||
default ResourceRegistry getResourceRegistry() {
|
||||
return getLogicalConnection().getResourceRegistry();
|
||||
}
|
||||
|
||||
void serialize(ObjectOutputStream objectOutputStream) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -19,14 +19,12 @@ import javax.persistence.FlushModeType;
|
|||
import javax.persistence.LockModeType;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.StoredProcedureQuery;
|
||||
import javax.persistence.SynchronizationType;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaDelete;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.CriteriaUpdate;
|
||||
import javax.persistence.criteria.Selection;
|
||||
import javax.persistence.metamodel.Metamodel;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.Criteria;
|
||||
|
@ -65,7 +63,7 @@ import org.hibernate.procedure.ProcedureCall;
|
|||
import org.hibernate.query.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.stat.SessionStatistics;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
|
@ -142,11 +140,6 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
|||
delegate.setAutoClear( enabled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableTransactionAutoJoin() {
|
||||
delegate.disableTransactionAutoJoin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransactionInProgress() {
|
||||
return delegate.isTransactionInProgress();
|
||||
|
@ -1116,16 +1109,6 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
|||
delegate.addEventListeners( listeners );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistenceUnitTransactionType getTransactionType() {
|
||||
return delegate.getTransactionType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynchronizationType getSynchronizationType() {
|
||||
return delegate.getSynchronizationType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlushBeforeCompletionEnabled() {
|
||||
return delegate.isFlushBeforeCompletionEnabled();
|
||||
|
|
|
@ -9,12 +9,10 @@ package org.hibernate.engine.spi;
|
|||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.persistence.SynchronizationType;
|
||||
import javax.persistence.criteria.CriteriaDelete;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.CriteriaUpdate;
|
||||
import javax.persistence.criteria.Selection;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
|
@ -22,6 +20,8 @@ import org.hibernate.jpa.spi.HibernateEntityManagerImplementor;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
|
||||
/**
|
||||
* Defines the "internal contract" for {@link Session} and other parts of Hibernate such as
|
||||
|
@ -34,8 +34,8 @@ import org.hibernate.query.spi.QueryImplementor;
|
|||
* {@link org.hibernate.resource.jdbc.spi.JdbcSessionContext} delegate
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link org.hibernate.resource.transaction.TransactionCoordinatorBuilder.TransactionCoordinatorOptions}
|
||||
* to drive the creation of the {@link org.hibernate.resource.transaction.TransactionCoordinator} delegate
|
||||
* {@link TransactionCoordinatorBuilder.Options}
|
||||
* to drive the creation of the {@link TransactionCoordinator} delegate
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link org.hibernate.engine.jdbc.LobCreationContext} to act as the context for JDBC LOB instance creation
|
||||
|
@ -54,13 +54,14 @@ import org.hibernate.query.spi.QueryImplementor;
|
|||
*/
|
||||
public interface SessionImplementor
|
||||
extends Session, SharedSessionContractImplementor, HibernateEntityManagerImplementor {
|
||||
PersistenceUnitTransactionType getTransactionType();
|
||||
SynchronizationType getSynchronizationType();
|
||||
|
||||
@Override
|
||||
SessionFactoryImplementor getSessionFactory();
|
||||
|
||||
// todo : isFlushBeforeCompletionEnabled is based on another value (SynchronizationType?), find usages of this and replace with that
|
||||
/**
|
||||
* @deprecated (since 5.2) use {@link #getHibernateFlushMode()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isFlushBeforeCompletionEnabled();
|
||||
|
||||
ActionQueue getActionQueue();
|
||||
|
|
|
@ -33,7 +33,9 @@ import org.hibernate.loader.custom.CustomQuery;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.spi.QueryProducerImplementor;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder.TransactionCoordinatorOptions;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder.Options;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
|
||||
/**
|
||||
|
@ -48,10 +50,10 @@ import org.hibernate.type.descriptor.WrapperOptions;
|
|||
* Can therefor be used to construct a JdbcCoordinator, which (for now) models a "JDBC session"
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link org.hibernate.resource.transaction.TransactionCoordinatorBuilder.TransactionCoordinatorOptions}
|
||||
* to drive the creation of the {@link org.hibernate.resource.transaction.TransactionCoordinator} delegate.
|
||||
* {@link Options}
|
||||
* to drive the creation of the {@link TransactionCoordinator} delegate.
|
||||
* This allows it to be passed along to
|
||||
* {@link org.hibernate.resource.transaction.TransactionCoordinatorBuilder#buildTransactionCoordinator}
|
||||
* {@link TransactionCoordinatorBuilder#buildTransactionCoordinator}
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link org.hibernate.engine.jdbc.LobCreationContext} to act as the context for JDBC LOB instance creation
|
||||
|
@ -66,7 +68,7 @@ import org.hibernate.type.descriptor.WrapperOptions;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SharedSessionContractImplementor
|
||||
extends SharedSessionContract, JdbcSessionOwner, TransactionCoordinatorOptions, LobCreationContext, WrapperOptions, QueryProducerImplementor, Serializable {
|
||||
extends SharedSessionContract, JdbcSessionOwner, Options, LobCreationContext, WrapperOptions, QueryProducerImplementor {
|
||||
|
||||
// todo : this is the shared contract between Session and StatelessSession, but it defines methods that StatelessSession does not implement
|
||||
// (it just throws UnsupportedOperationException). To me it seems like it is better to properly isolate those methods
|
||||
|
@ -196,19 +198,6 @@ public interface SharedSessionContractImplementor
|
|||
*/
|
||||
long getTimestamp();
|
||||
|
||||
/**
|
||||
* Disable automatic transaction joining. The really only has any effect for CMT transactions. The default
|
||||
* Hibernate behavior is to auto join any active JTA transaction (register {@link javax.transaction.Synchronization}).
|
||||
* JPA however defines an explicit join transaction operation.
|
||||
* <p/>
|
||||
* See javax.persistence.EntityManager#joinTransaction
|
||||
*
|
||||
* @deprecated (since 5.2) (1) this is not supported in StatelessSession and (2) this is based
|
||||
* on SynchronizationType and in Session hierarchy we should just leverage {@link SessionImplementor#getSynchronizationType()}
|
||||
*/
|
||||
@Deprecated
|
||||
void disableTransactionAutoJoin();
|
||||
|
||||
/**
|
||||
* Does this <tt>Session</tt> have an active Hibernate transaction
|
||||
* or is there a JTA transaction in progress?
|
||||
|
|
|
@ -12,12 +12,12 @@ import org.hibernate.HibernateException;
|
|||
import org.hibernate.TransactionException;
|
||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.hibernate.resource.transaction.TransactionCoordinator.TransactionDriver;
|
||||
import static org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.hibernate.engine.spi.SessionImplementor;
|
|||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder.TransactionCoordinatorOptions;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder.Options;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,8 @@ import org.hibernate.type.descriptor.WrapperOptions;
|
|||
*/
|
||||
public abstract class AbstractSessionImpl
|
||||
extends AbstractSharedSessionContract
|
||||
implements Serializable, SharedSessionContractImplementor, JdbcSessionOwner, SessionImplementor, EventSource, TransactionCoordinatorOptions, WrapperOptions {
|
||||
implements Serializable, SharedSessionContractImplementor, JdbcSessionOwner, SessionImplementor, EventSource,
|
||||
Options, WrapperOptions {
|
||||
|
||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( AbstractSessionImpl.class );
|
||||
|
||||
|
@ -30,7 +31,4 @@ public abstract class AbstractSessionImpl
|
|||
super( factory, options );
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean shouldAutoJoinTransaction();
|
||||
|
||||
}
|
||||
|
|
|
@ -20,13 +20,10 @@ import javax.persistence.LockTimeoutException;
|
|||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.NonUniqueResultException;
|
||||
import javax.persistence.OptimisticLockException;
|
||||
import javax.persistence.PersistenceContextType;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.PessimisticLockException;
|
||||
import javax.persistence.QueryTimeoutException;
|
||||
import javax.persistence.SynchronizationType;
|
||||
import javax.persistence.Tuple;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.CacheMode;
|
||||
|
@ -96,11 +93,10 @@ import org.hibernate.query.internal.QueryImpl;
|
|||
import org.hibernate.query.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
@ -126,36 +122,28 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
|||
public abstract class AbstractSharedSessionContract implements SharedSessionContractImplementor {
|
||||
private static final EntityManagerMessageLogger log = HEMLogging.messageLogger( SessionImpl.class );
|
||||
|
||||
private final SessionFactoryImpl factory;
|
||||
private transient SessionFactoryImpl factory;
|
||||
private final String tenantIdentifier;
|
||||
private final UUID sessionIdentifier;
|
||||
|
||||
// todo : (5.2) review synchronizationType, persistenceContextType, transactionType usage
|
||||
|
||||
private transient PhysicalConnectionHandlingMode connectionHandlingMode;
|
||||
// SynchronizationType -> should we auto enlist in transactions
|
||||
private transient SynchronizationType synchronizationType;
|
||||
// PersistenceUnitTransactionType -> what type of TransactionCoordinator(Builder) to use;
|
||||
// according to JPA should technically also disallow access to Transaction object for
|
||||
// JTA environments
|
||||
private transient PersistenceUnitTransactionType transactionType;
|
||||
// PersistenceContextType -> influences FlushMode and 'autoClose'
|
||||
private transient PersistenceContextType persistenceContextType;
|
||||
|
||||
private final boolean isTransactionCoordinatorShared;
|
||||
private final TransactionCoordinator transactionCoordinator;
|
||||
private final JdbcCoordinator jdbcCoordinator;
|
||||
private final Interceptor interceptor;
|
||||
private final JdbcSessionContext jdbcSessionContext;
|
||||
private final EntityNameResolver entityNameResolver;
|
||||
|
||||
private FlushMode flushMode;
|
||||
private boolean autoJoinTransactions;
|
||||
|
||||
private CacheMode cacheMode;
|
||||
|
||||
private boolean closed;
|
||||
|
||||
// transient & non-final for Serialization purposes - ugh
|
||||
private transient SessionEventListenerManagerImpl sessionEventsManager = new SessionEventListenerManagerImpl();
|
||||
private transient EntityNameResolver entityNameResolver;
|
||||
private transient JdbcConnectionAccess jdbcConnectionAccess;
|
||||
private transient JdbcSessionContext jdbcSessionContext;
|
||||
private transient JdbcCoordinator jdbcCoordinator;
|
||||
private transient TransactionImplementor currentHibernateTransaction;
|
||||
private transient TransactionCoordinator transactionCoordinator;
|
||||
private transient Boolean useStreamForLobBinding;
|
||||
private transient long timestamp;
|
||||
|
||||
|
@ -164,9 +152,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
this.sessionIdentifier = StandardRandomStrategy.INSTANCE.generateUUID( null );
|
||||
this.timestamp = factory.getCache().getRegionFactory().nextTimestamp();
|
||||
|
||||
this.transactionType = options.getPersistenceUnitTransactionType();
|
||||
this.synchronizationType = options.getSynchronizationType();
|
||||
this.persistenceContextType = PersistenceContextType.TRANSACTION;
|
||||
this.flushMode = options.getInitialSessionFlushMode();
|
||||
|
||||
this.tenantIdentifier = options.getTenantIdentifier();
|
||||
if ( MultiTenancyStrategy.NONE == factory.getSettings().getMultiTenancyStrategy() ) {
|
||||
|
@ -201,11 +187,12 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
// todo : "wrap" the transaction to no-op cmmit/rollback attempts?
|
||||
this.currentHibernateTransaction = sharedOptions.getTransaction();
|
||||
|
||||
if ( sharedOptions.getSynchronizationType() != null ) {
|
||||
if ( sharedOptions.shouldAutoJoinTransactions() ) {
|
||||
log.debug(
|
||||
"Session creation specified 'autoJoinTransactions', which is invalid in conjunction " +
|
||||
"with sharing JDBC connection between sessions; ignoring"
|
||||
);
|
||||
autoJoinTransactions = false;
|
||||
}
|
||||
if ( sharedOptions.getPhysicalConnectionHandlingMode() != this.jdbcCoordinator.getLogicalConnection().getConnectionHandlingMode() ) {
|
||||
log.debug(
|
||||
|
@ -218,6 +205,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
}
|
||||
else {
|
||||
this.isTransactionCoordinatorShared = false;
|
||||
this.autoJoinTransactions = options.shouldAutoJoinTransactions();
|
||||
|
||||
this.jdbcCoordinator = new JdbcCoordinatorImpl( options.getConnection(), this );
|
||||
this.transactionCoordinator = factory.getServiceRegistry()
|
||||
|
@ -232,6 +220,11 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
protected void addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAutoJoinTransaction() {
|
||||
return autoJoinTransactions;
|
||||
}
|
||||
|
||||
private Interceptor interpret(Interceptor interceptor) {
|
||||
return interceptor == null ? EmptyInterceptor.INSTANCE : interceptor;
|
||||
}
|
||||
|
@ -290,24 +283,6 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
return tenantIdentifier;
|
||||
}
|
||||
|
||||
public SynchronizationType getSynchronizationType() {
|
||||
return synchronizationType;
|
||||
}
|
||||
|
||||
public PersistenceUnitTransactionType getTransactionType() {
|
||||
return transactionType;
|
||||
}
|
||||
|
||||
public PersistenceContextType getPersistenceContextType() {
|
||||
return persistenceContextType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableTransactionAutoJoin() {
|
||||
checkOpen();
|
||||
synchronizationType = SynchronizationType.UNSYNCHRONIZED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
|
@ -1170,7 +1145,8 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
return scrollCustomQuery( getNativeQueryPlan( spec ).getCustomQuery(), queryParameters );
|
||||
}
|
||||
|
||||
protected void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
@SuppressWarnings("unused")
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
log.trace( "Serializing " + getClass().getSimpleName() + " [" );
|
||||
|
||||
if ( !jdbcCoordinator.isReadyForSerialization() ) {
|
||||
|
@ -1179,6 +1155,10 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
throw new IllegalStateException( "Cannot serialize " + getClass().getSimpleName() + " [" + getSessionIdentifier() + "] while connected" );
|
||||
}
|
||||
|
||||
if ( isTransactionCoordinatorShared ) {
|
||||
throw new IllegalStateException( "Cannot serialize " + getClass().getSimpleName() + " [" + getSessionIdentifier() + "] as it has a shared TransactionCoordinator" );
|
||||
}
|
||||
|
||||
// todo : (5.2) come back and review serialization plan...
|
||||
// this was done quickly during initial HEM consolidation into CORE and is likely not perfect :)
|
||||
//
|
||||
|
@ -1190,10 +1170,14 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Step 2 :: write transient state...
|
||||
// -- none that we want to serialize atm (see concurrent access discussion)
|
||||
// -- see concurrent access discussion
|
||||
|
||||
factory.serialize( oos );
|
||||
oos.writeObject( jdbcSessionContext.getStatementInspector() );
|
||||
jdbcCoordinator.serialize( oos );
|
||||
}
|
||||
|
||||
protected void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException, SQLException {
|
||||
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException, SQLException {
|
||||
log.trace( "Deserializing " + getClass().getSimpleName() );
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -1202,7 +1186,16 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Step 2 :: read back transient state...
|
||||
// -- again none, see above
|
||||
// -- see above
|
||||
|
||||
factory = SessionFactoryImpl.deserialize( ois );
|
||||
jdbcSessionContext = new JdbcSessionContextImpl( this, (StatementInspector) ois.readObject() );
|
||||
jdbcCoordinator = JdbcCoordinatorImpl.deserialize( ois, this );
|
||||
|
||||
this.transactionCoordinator = factory.getServiceRegistry()
|
||||
.getService( TransactionCoordinatorBuilder.class )
|
||||
.buildTransactionCoordinator( jdbcCoordinator, this );
|
||||
|
||||
entityNameResolver = new CoordinatingEntityNameResolver( factory, interceptor );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
import java.sql.Connection;
|
||||
import javax.persistence.SynchronizationType;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.Interceptor;
|
||||
import org.hibernate.engine.spi.SessionOwner;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
|
@ -25,22 +24,13 @@ public interface SessionCreationOptions {
|
|||
// todo : (5.2) review this. intended as a consolidation of the options needed to create a Session
|
||||
// comes from building a Session and a EntityManager
|
||||
|
||||
/**
|
||||
* Access to the SessionOwner, which defines the contract for things that can wrap a Session
|
||||
*
|
||||
* @return The SessionOwner
|
||||
*
|
||||
* @deprecated since 6.0 SessionOwner is no longer pertinent due to the
|
||||
* hibernate-entitymanager -> hibernate-core consolidation
|
||||
*/
|
||||
@Deprecated
|
||||
SessionOwner getSessionOwner();
|
||||
boolean shouldAutoJoinTransactions();
|
||||
|
||||
ExceptionMapper getExceptionMapper();
|
||||
FlushMode getInitialSessionFlushMode();
|
||||
|
||||
AfterCompletionAction getAfterCompletionAction();
|
||||
boolean shouldAutoClose();
|
||||
|
||||
ManagedFlushChecker getManagedFlushChecker();
|
||||
boolean shouldAutoClear();
|
||||
|
||||
Connection getConnection();
|
||||
|
||||
|
@ -52,15 +42,25 @@ public interface SessionCreationOptions {
|
|||
|
||||
String getTenantIdentifier();
|
||||
|
||||
PersistenceUnitTransactionType getPersistenceUnitTransactionType();
|
||||
|
||||
SynchronizationType getSynchronizationType();
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// deprecations
|
||||
|
||||
boolean isClearStateOnCloseEnabled();
|
||||
/**
|
||||
* Access to the SessionOwner, which defines the contract for things that can wrap a Session
|
||||
*
|
||||
* @return The SessionOwner
|
||||
*
|
||||
* @deprecated (since 5,2) SessionOwner is no longer pertinent due to the
|
||||
* hibernate-entitymanager -> hibernate-core consolidation
|
||||
*/
|
||||
@Deprecated
|
||||
SessionOwner getSessionOwner();
|
||||
|
||||
boolean isFlushBeforeCompletionEnabled();
|
||||
ExceptionMapper getExceptionMapper();
|
||||
|
||||
AfterCompletionAction getAfterCompletionAction();
|
||||
|
||||
ManagedFlushChecker getManagedFlushChecker();
|
||||
|
||||
// not sure of these are needed
|
||||
// boolean isAutoCloseSessionEnabled();
|
||||
// PersistenceContextType getPersistenceContextType();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||
import javax.naming.Reference;
|
||||
import javax.naming.StringRefAddr;
|
||||
import javax.persistence.EntityGraph;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContextType;
|
||||
import javax.persistence.PersistenceUnitUtil;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.SynchronizationType;
|
||||
|
@ -36,6 +36,7 @@ import org.hibernate.ConnectionReleaseMode;
|
|||
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||
import org.hibernate.EmptyInterceptor;
|
||||
import org.hibernate.EntityNameResolver;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Interceptor;
|
||||
import org.hibernate.MappingException;
|
||||
|
@ -107,6 +108,7 @@ import org.hibernate.resource.jdbc.spi.StatementInspector;
|
|||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.AfterCompletionAction;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ExceptionMapper;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ManagedFlushChecker;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.secure.spi.GrantedPermission;
|
||||
import org.hibernate.secure.spi.JaccPermissionDeclarations;
|
||||
import org.hibernate.secure.spi.JaccService;
|
||||
|
@ -553,24 +555,60 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// todo : (5.2) review synchronizationType, persistenceContextType, transactionType usage
|
||||
|
||||
// SynchronizationType -> should we auto enlist in transactions
|
||||
private transient SynchronizationType synchronizationType;
|
||||
|
||||
// PersistenceContextType -> influences FlushMode and 'autoClose'
|
||||
private transient PersistenceContextType persistenceContextType;
|
||||
|
||||
|
||||
@Override
|
||||
public EntityManager createEntityManager() {
|
||||
return null;
|
||||
public Session createEntityManager() {
|
||||
return buildEntityManager( SynchronizationType.SYNCHRONIZED, Collections.emptyMap() );
|
||||
}
|
||||
|
||||
private Session buildEntityManager(SynchronizationType synchronizationType, Map map) {
|
||||
SessionBuilderImplementor builder = withOptions();
|
||||
if ( synchronizationType == SynchronizationType.SYNCHRONIZED ) {
|
||||
builder.autoJoinTransactions( true );
|
||||
}
|
||||
else {
|
||||
builder.autoJoinTransactions( false );
|
||||
}
|
||||
return builder.openSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityManager createEntityManager(Map map) {
|
||||
return null;
|
||||
public Session createEntityManager(Map map) {
|
||||
return buildEntityManager( SynchronizationType.SYNCHRONIZED, map );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityManager createEntityManager(SynchronizationType synchronizationType) {
|
||||
return null;
|
||||
public Session createEntityManager(SynchronizationType synchronizationType) {
|
||||
errorIfResourceLocalDueToExplicitSynchronizationType();
|
||||
return buildEntityManager( synchronizationType, Collections.emptyMap() );
|
||||
}
|
||||
|
||||
private void errorIfResourceLocalDueToExplicitSynchronizationType() {
|
||||
// JPA requires that we throw IllegalStateException in cases where:
|
||||
// 1) the PersistenceUnitTransactionType (TransactionCoordinator) is non-JTA
|
||||
// 2) an explicit SynchronizationType is specified
|
||||
if ( !getServiceRegistry().getService( TransactionCoordinatorBuilder.class ).isJta() ) {
|
||||
throw new IllegalStateException(
|
||||
"Illegal attempt to specify a SynchronizationType when building an EntityManager from a " +
|
||||
"EntityManagerFactory defined as RESOURCE_LOCAL (as opposed to JTA)"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) {
|
||||
return null;
|
||||
public Session createEntityManager(SynchronizationType synchronizationType, Map map) {
|
||||
errorIfResourceLocalDueToExplicitSynchronizationType();
|
||||
return buildEntityManager( synchronizationType, map );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -884,9 +922,10 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
private StatementInspector statementInspector;
|
||||
private Connection connection;
|
||||
private PhysicalConnectionHandlingMode connectionHandlingMode;
|
||||
private boolean autoClose;
|
||||
private boolean autoJoinTransactions = true;
|
||||
private boolean flushBeforeCompletion;
|
||||
private FlushMode flushMode;
|
||||
private boolean autoClose;
|
||||
private boolean autoClear;
|
||||
private String tenantIdentifier;
|
||||
private List<SessionEventListener> listeners;
|
||||
|
||||
|
@ -902,7 +941,9 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
this.statementInspector = sessionFactory.getSessionFactoryOptions().getStatementInspector();
|
||||
this.connectionHandlingMode = sessionFactory.getSessionFactoryOptions().getPhysicalConnectionHandlingMode();
|
||||
this.autoClose = sessionFactory.getSessionFactoryOptions().isAutoCloseSessionEnabled();
|
||||
this.flushBeforeCompletion = sessionFactory.getSessionFactoryOptions().isFlushBeforeCompletionEnabled();
|
||||
this.flushMode = sessionFactory.getSessionFactoryOptions().isFlushBeforeCompletionEnabled()
|
||||
? FlushMode.AUTO
|
||||
: FlushMode.MANUAL;
|
||||
|
||||
if ( sessionFactory.getCurrentTenantIdentifierResolver() != null ) {
|
||||
tenantIdentifier = sessionFactory.getCurrentTenantIdentifierResolver().resolveCurrentTenantIdentifier();
|
||||
|
@ -952,6 +993,26 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAutoJoinTransactions() {
|
||||
return autoJoinTransactions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlushMode getInitialSessionFlushMode() {
|
||||
return flushMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAutoClose() {
|
||||
return autoClose;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAutoClear() {
|
||||
return autoClear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
|
@ -995,26 +1056,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
return tenantIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistenceUnitTransactionType getPersistenceUnitTransactionType() {
|
||||
return persistenceUnitTransactionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynchronizationType getSynchronizationType() {
|
||||
return autoJoinTransactions ? SynchronizationType.SYNCHRONIZED : SynchronizationType.UNSYNCHRONIZED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClearStateOnCloseEnabled() {
|
||||
return autoClose;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlushBeforeCompletionEnabled() {
|
||||
return flushBeforeCompletion;
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// SessionBuilder
|
||||
|
@ -1103,8 +1144,15 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public T flushBeforeCompletion(boolean flushBeforeCompletion) {
|
||||
this.flushBeforeCompletion = flushBeforeCompletion;
|
||||
public T autoClear(boolean autoClear) {
|
||||
this.autoClear = autoClear;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public T flushMode(FlushMode flushMode) {
|
||||
this.flushMode = flushMode;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
@ -1128,13 +1176,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
listeners.clear();
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public T persistenceUnitTransactionType(PersistenceUnitTransactionType persistenceUnitTransactionType) {
|
||||
this.persistenceUnitTransactionType = persistenceUnitTransactionType;
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class StatelessSessionBuilderImpl implements StatelessSessionBuilder, SessionCreationOptions {
|
||||
|
@ -1168,23 +1209,23 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SessionOwner getSessionOwner() {
|
||||
return null;
|
||||
public boolean shouldAutoJoinTransactions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExceptionMapper getExceptionMapper() {
|
||||
return null;
|
||||
public FlushMode getInitialSessionFlushMode() {
|
||||
return FlushMode.ALWAYS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AfterCompletionAction getAfterCompletionAction() {
|
||||
return null;
|
||||
public boolean shouldAutoClose() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedFlushChecker getManagedFlushChecker() {
|
||||
return null;
|
||||
public boolean shouldAutoClear() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1227,23 +1268,23 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PersistenceUnitTransactionType getPersistenceUnitTransactionType() {
|
||||
public SessionOwner getSessionOwner() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynchronizationType getSynchronizationType() {
|
||||
public ExceptionMapper getExceptionMapper() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClearStateOnCloseEnabled() {
|
||||
return false;
|
||||
public AfterCompletionAction getAfterCompletionAction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlushBeforeCompletionEnabled() {
|
||||
return false;
|
||||
public ManagedFlushChecker getManagedFlushChecker() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,13 +39,11 @@ import javax.persistence.LockTimeoutException;
|
|||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.NonUniqueResultException;
|
||||
import javax.persistence.OptimisticLockException;
|
||||
import javax.persistence.PersistenceContextType;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.PessimisticLockException;
|
||||
import javax.persistence.PessimisticLockScope;
|
||||
import javax.persistence.QueryTimeoutException;
|
||||
import javax.persistence.StoredProcedureQuery;
|
||||
import javax.persistence.SynchronizationType;
|
||||
import javax.persistence.TransactionRequiredException;
|
||||
import javax.persistence.Tuple;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
|
@ -53,17 +51,13 @@ import javax.persistence.criteria.CriteriaDelete;
|
|||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.CriteriaUpdate;
|
||||
import javax.persistence.criteria.Selection;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.EmptyInterceptor;
|
||||
import org.hibernate.Filter;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.IdentifierLoadAccess;
|
||||
import org.hibernate.Interceptor;
|
||||
import org.hibernate.LobHelper;
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
|
@ -188,14 +182,12 @@ import org.hibernate.query.criteria.internal.expression.CompoundSelectionImpl;
|
|||
import org.hibernate.query.internal.CollectionFilterImpl;
|
||||
import org.hibernate.query.procedure.internal.StoredProcedureQueryImpl;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.TransactionRequiredForJoinException;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.AfterCompletionAction;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ExceptionMapper;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ManagedFlushChecker;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
import org.hibernate.stat.SessionStatistics;
|
||||
import org.hibernate.stat.internal.SessionStatisticsImpl;
|
||||
|
@ -204,7 +196,6 @@ import static org.hibernate.cfg.AvailableSettings.JPA_LOCK_SCOPE;
|
|||
import static org.hibernate.cfg.AvailableSettings.JPA_LOCK_TIMEOUT;
|
||||
import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE;
|
||||
import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_STORE_MODE;
|
||||
import static org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION;
|
||||
|
||||
/**
|
||||
* Concrete implementation of a Session.
|
||||
|
@ -247,25 +238,21 @@ public final class SessionImpl
|
|||
|
||||
private transient LoadQueryInfluencers loadQueryInfluencers;
|
||||
|
||||
// todo : (5.2) HEM always initialized this. Is that really needed?
|
||||
private LockOptions lockOptions = new LockOptions();
|
||||
|
||||
private transient boolean autoClear;
|
||||
private transient boolean autoClose;
|
||||
|
||||
private transient int dontFlushFromFind;
|
||||
|
||||
private transient ExceptionMapper exceptionMapper;
|
||||
private transient ManagedFlushChecker managedFlushChecker;
|
||||
private transient AfterCompletionAction afterCompletionAction;
|
||||
|
||||
// todo : (5.2) HEM always initialized this. Is that really needed?
|
||||
private LockOptions lockOptions = new LockOptions();
|
||||
|
||||
// todo : (5.2) are these still really needed?
|
||||
private transient boolean autoClear; //for EJB3
|
||||
private transient boolean flushBeforeCompletionEnabled;
|
||||
private transient boolean autoCloseSessionEnabled;
|
||||
|
||||
private transient int dontFlushFromFind;
|
||||
|
||||
|
||||
private transient LoadEvent loadEvent; //cached LoadEvent instance
|
||||
|
||||
|
||||
|
||||
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
|
||||
super( factory, options );
|
||||
|
||||
|
@ -275,49 +262,17 @@ public final class SessionImpl
|
|||
this.sessionOwner = options.getSessionOwner();
|
||||
initializeFromSessionOwner( sessionOwner );
|
||||
|
||||
this.autoClear = options.isClearStateOnCloseEnabled();
|
||||
this.flushBeforeCompletionEnabled = options.isFlushBeforeCompletionEnabled();
|
||||
this.autoClear = options.shouldAutoClear();
|
||||
this.autoClose = options.shouldAutoClose();
|
||||
|
||||
if ( options instanceof SharedSessionCreationOptions && ( (SharedSessionCreationOptions) options ).isTransactionCoordinatorShared() ) {
|
||||
final SharedSessionCreationOptions sharedOptions = (SharedSessionCreationOptions) options;
|
||||
if ( sharedOptions.getTransactionCompletionProcesses() != null ) {
|
||||
actionQueue.setTransactionCompletionProcesses( sharedOptions.getTransactionCompletionProcesses(), true );
|
||||
}
|
||||
|
||||
getTransactionCoordinator().addObserver(
|
||||
new TransactionObserver() {
|
||||
@Override
|
||||
public void afterBegin() {
|
||||
log.tracef( "TransactionObserver#afterBegin on Session [%s]", getSessionIdentifier() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCompletion() {
|
||||
log.tracef( "TransactionObserver#beforeCompletion on Session [%s]", getSessionIdentifier() );
|
||||
if ( isOpen() && flushBeforeCompletionEnabled ) {
|
||||
SessionImpl.this.managedFlush();
|
||||
}
|
||||
actionQueue.beforeTransactionCompletion();
|
||||
try {
|
||||
getInterceptor().beforeTransactionCompletion( getTransaction() );
|
||||
}
|
||||
catch (Throwable t) {
|
||||
log.exceptionInBeforeTransactionCompletionInterceptor( t );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(boolean successful, boolean delayed) {
|
||||
log.tracef( "TransactionObserver#afterCompletion(%s, %s) on Session [%s]", successful, delayed, getSessionIdentifier() );
|
||||
afterTransactionCompletion( successful, delayed );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
this.autoCloseSessionEnabled = getPersistenceContextType() == PersistenceContextType.TRANSACTION
|
||||
&& factory.getSessionFactoryOptions().isAutoCloseSessionEnabled();
|
||||
this.autoClose = options.shouldAutoClose();
|
||||
}
|
||||
|
||||
loadQueryInfluencers = new LoadQueryInfluencers( factory );
|
||||
|
@ -337,41 +292,6 @@ public final class SessionImpl
|
|||
}
|
||||
}
|
||||
|
||||
private PhysicalConnectionHandlingMode interpret(
|
||||
Connection userSuppliedConnection,
|
||||
PhysicalConnectionHandlingMode connectionHandlingMode) {
|
||||
if ( userSuppliedConnection != null ) {
|
||||
return DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION;
|
||||
}
|
||||
|
||||
if ( connectionHandlingMode == null ) {
|
||||
connectionHandlingMode = getFactory().getSessionFactoryOptions().getPhysicalConnectionHandlingMode();
|
||||
}
|
||||
|
||||
if ( connectionHandlingMode.getReleaseMode() == ConnectionReleaseMode.AFTER_STATEMENT ) {
|
||||
if ( !getJdbcConnectionAccess().supportsAggressiveRelease() ) {
|
||||
log.debug( "Connection provider reports to not support aggressive release; overriding" );
|
||||
return PhysicalConnectionHandlingMode.interpret(
|
||||
connectionHandlingMode.getAcquisitionMode(),
|
||||
ConnectionReleaseMode.AFTER_TRANSACTION
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return connectionHandlingMode;
|
||||
}
|
||||
|
||||
private Interceptor interpret(Interceptor interceptor) {
|
||||
return interceptor == null ? EmptyInterceptor.INSTANCE : interceptor;
|
||||
}
|
||||
|
||||
private StatementInspector interpret(StatementInspector statementInspector) {
|
||||
if ( statementInspector == null ) {
|
||||
return (StatementInspector) sql -> getInterceptor().onPrepareStatement( sql );
|
||||
}
|
||||
return statementInspector;
|
||||
}
|
||||
|
||||
private void setDefaultProperties() {
|
||||
properties.putIfAbsent( AvailableSettings.FLUSH_MODE, getHibernateFlushMode() );
|
||||
properties.putIfAbsent( JPA_LOCK_SCOPE, PessimisticLockScope.EXTENDED.name() );
|
||||
|
@ -414,144 +334,6 @@ public final class SessionImpl
|
|||
return determineCacheStoreMode( properties );
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Constructor used for openSession(...) processing, as well as construction
|
||||
// * of sessions for getCurrentSession().
|
||||
// *
|
||||
// * @param connection The user-supplied connection to use for this session.
|
||||
// * @param factory The factory from which this session was obtained
|
||||
// * @param transactionCoordinator The transaction coordinator to use, may be null to indicate that a new transaction
|
||||
// * coordinator should get created.
|
||||
// * @param autoJoinTransactions Should the session automatically join JTA transactions?
|
||||
// * @param timestamp The timestamp for this session
|
||||
// * @param interceptor The interceptor to be applied to this session
|
||||
// * @param flushBeforeCompletionEnabled Should we auto flush beforeQuery completion of transaction
|
||||
// * @param autoCloseSessionEnabled Should we auto close afterQuery completion of transaction
|
||||
// * @param connectionReleaseMode The mode by which we should release JDBC connections.
|
||||
// * @param tenantIdentifier The tenant identifier to use. May be null
|
||||
// */
|
||||
// SessionImpl(
|
||||
// final Connection connection,
|
||||
// final SessionFactoryImpl factory,
|
||||
// final SessionOwner sessionOwner,
|
||||
// final TransactionCoordinator transactionCoordinator,
|
||||
// final JdbcCoordinatorImpl jdbcCoordinator,
|
||||
// final Transaction transaction,
|
||||
// final ActionQueue.TransactionCompletionProcesses transactionCompletionProcesses,
|
||||
// final boolean autoJoinTransactions,
|
||||
// final long timestamp,
|
||||
// final Interceptor interceptor,
|
||||
// final StatementInspector statementInspector,
|
||||
// final boolean flushBeforeCompletionEnabled,
|
||||
// final boolean autoCloseSessionEnabled,
|
||||
// final ConnectionReleaseMode connectionReleaseMode,
|
||||
// final String tenantIdentifier) {
|
||||
// super( factory, tenantIdentifier );
|
||||
// this.timestamp = timestamp;
|
||||
// this.sessionOwner = sessionOwner;
|
||||
// this.interceptor = interceptor == null ? EmptyInterceptor.INSTANCE : interceptor;
|
||||
// this.actionQueue = new ActionQueue( this );
|
||||
// this.persistenceContext = new StatefulPersistenceContext( this );
|
||||
//
|
||||
// this.autoCloseSessionEnabled = autoCloseSessionEnabled;
|
||||
// this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
|
||||
//
|
||||
// initializeFromSessionOwner( sessionOwner );
|
||||
//
|
||||
// if ( statementInspector == null ) {
|
||||
// this.statementInspector = new StatementInspector() {
|
||||
// @Override
|
||||
// @SuppressWarnings("deprecation")
|
||||
// public String inspect(String sql) {
|
||||
// return SessionImpl.this.interceptor.onPrepareStatement( sql );
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
// else {
|
||||
// this.statementInspector = statementInspector;
|
||||
// }
|
||||
// this.jdbcSessionContext = new JdbcSessionContextImpl( factory, this.statementInspector );
|
||||
//
|
||||
// if ( transactionCoordinator == null ) {
|
||||
// this.isTransactionCoordinatorShared = false;
|
||||
// this.connectionReleaseMode = connectionReleaseMode;
|
||||
// this.autoJoinTransactions = autoJoinTransactions;
|
||||
//
|
||||
// this.jdbcCoordinator = new JdbcCoordinatorImpl( connection, this );
|
||||
// this.transactionCoordinator = getTransactionCoordinatorBuilder().buildTransactionCoordinator(
|
||||
// this.jdbcCoordinator,
|
||||
// this
|
||||
// );
|
||||
// this.currentHibernateTransaction = getTransaction();
|
||||
// }
|
||||
// else {
|
||||
// if ( connection != null ) {
|
||||
// throw new SessionException( "Cannot simultaneously share transaction context and specify connection" );
|
||||
// }
|
||||
// this.transactionCoordinator = transactionCoordinator;
|
||||
// this.jdbcCoordinator = jdbcCoordinator;
|
||||
// this.currentHibernateTransaction = transaction;
|
||||
// this.isTransactionCoordinatorShared = true;
|
||||
// this.autoJoinTransactions = false;
|
||||
// if ( transactionCompletionProcesses != null ) {
|
||||
// actionQueue.setTransactionCompletionProcesses( transactionCompletionProcesses, true );
|
||||
// }
|
||||
// if ( autoJoinTransactions ) {
|
||||
// log.debug(
|
||||
// "Session creation specified 'autoJoinTransactions', which is invalid in conjunction " +
|
||||
// "with sharing JDBC connection between sessions; ignoring"
|
||||
// );
|
||||
// }
|
||||
// if ( connectionReleaseMode != this.jdbcCoordinator.getConnectionReleaseMode() ) {
|
||||
// log.debug(
|
||||
// "Session creation specified 'getConnectionReleaseMode', which is invalid in conjunction " +
|
||||
// "with sharing JDBC connection between sessions; ignoring"
|
||||
// );
|
||||
// }
|
||||
// this.connectionReleaseMode = this.jdbcCoordinator.getConnectionReleaseMode();
|
||||
//
|
||||
// transactionObserver = new TransactionObserver() {
|
||||
// @Override
|
||||
// public void afterBegin() {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void beforeCompletion() {
|
||||
// if ( isOpen() && flushBeforeCompletionEnabled ) {
|
||||
// SessionImpl.this.managedFlush();
|
||||
// }
|
||||
// actionQueue.beforeTransactionCompletion();
|
||||
// try {
|
||||
// SessionImpl.this.interceptor.beforeTransactionCompletion( currentHibernateTransaction );
|
||||
// }
|
||||
// catch (Throwable t) {
|
||||
// log.exceptionInBeforeTransactionCompletionInterceptor( t );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void afterCompletion(boolean successful, boolean delayed) {
|
||||
// afterTransactionCompletion( successful, delayed );
|
||||
// if ( !isClosed() && autoCloseSessionEnabled ) {
|
||||
// managedClose();
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// transactionCoordinator.addObserver( transactionObserver );
|
||||
// }
|
||||
//
|
||||
// loadQueryInfluencers = new LoadQueryInfluencers( factory );
|
||||
//
|
||||
// if ( factory.getStatistics().isStatisticsEnabled() ) {
|
||||
// factory.getStatistics().openSession();
|
||||
// }
|
||||
//
|
||||
// if ( TRACE_ENABLED ) {
|
||||
// log.tracef( "Opened session at timestamp: %s", timestamp );
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
private void initializeFromSessionOwner(SessionOwner sessionOwner) {
|
||||
if ( sessionOwner != null ) {
|
||||
|
@ -658,12 +440,7 @@ public final class SessionImpl
|
|||
|
||||
@Override
|
||||
public boolean isAutoCloseSessionEnabled() {
|
||||
return autoCloseSessionEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAutoJoinTransaction() {
|
||||
return getSynchronizationType() == SynchronizationType.SYNCHRONIZED;
|
||||
return autoClose;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -708,6 +485,9 @@ public final class SessionImpl
|
|||
return sessionOwner.shouldAutoCloseSession();
|
||||
}
|
||||
else {
|
||||
// JPA technically requires that this be a PersistentUnityTransactionType#JTA to work,
|
||||
// but we do not assert that here...
|
||||
//return isAutoCloseSessionEnabled() && getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta();
|
||||
return isAutoCloseSessionEnabled();
|
||||
}
|
||||
}
|
||||
|
@ -2480,7 +2260,11 @@ public final class SessionImpl
|
|||
public void afterTransactionCompletion(boolean successful, boolean delayed) {
|
||||
log.tracef( "SessionImpl#afterTransactionCompletion(successful=%s, delayed=%s)", successful, delayed );
|
||||
|
||||
afterCompletionAction.doAction( successful, this );
|
||||
if ( !isClosed() ) {
|
||||
if ( !successful && autoClear ) {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
persistenceContext.afterTransactionCompletion();
|
||||
actionQueue.afterTransactionCompletion( successful );
|
||||
|
@ -2503,20 +2287,6 @@ public final class SessionImpl
|
|||
managedClose();
|
||||
}
|
||||
}
|
||||
|
||||
if ( autoClear ) {
|
||||
internalClear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistenceUnitTransactionType getTransactionType() {
|
||||
return super.getTransactionType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynchronizationType getSynchronizationType() {
|
||||
return super.getSynchronizationType();
|
||||
}
|
||||
|
||||
private static class LobHelperImpl implements LobHelper {
|
||||
|
@ -2614,13 +2384,13 @@ public final class SessionImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public T autoClose() {
|
||||
return autoClose( session.autoCloseSessionEnabled );
|
||||
public T flushMode() {
|
||||
return flushMode( session.getHibernateFlushMode() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public T flushBeforeCompletion() {
|
||||
return flushBeforeCompletion( session.flushBeforeCompletionEnabled );
|
||||
public T autoClose() {
|
||||
return autoClose( session.autoClose );
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -2717,7 +2487,7 @@ public final class SessionImpl
|
|||
|
||||
@Override
|
||||
public void beforeCompletion() {
|
||||
if ( isOpen() && flushBeforeCompletionEnabled ) {
|
||||
if ( isOpen() && getHibernateFlushMode() != FlushMode.MANUAL ) {
|
||||
managedFlush();
|
||||
}
|
||||
actionQueue.beforeTransactionCompletion();
|
||||
|
@ -2732,7 +2502,7 @@ public final class SessionImpl
|
|||
@Override
|
||||
public void afterCompletion(boolean successful, boolean delayed) {
|
||||
afterTransactionCompletion( successful, delayed );
|
||||
if ( !isClosed() && autoCloseSessionEnabled ) {
|
||||
if ( !isClosed() && autoClose ) {
|
||||
managedClose();
|
||||
}
|
||||
}
|
||||
|
@ -3221,9 +2991,12 @@ public final class SessionImpl
|
|||
|
||||
@Override
|
||||
public void flushBeforeTransactionCompletion() {
|
||||
boolean flush = isTransactionFlushable() && managedFlushChecker.shouldDoManagedFlush( this );
|
||||
final boolean doFlush = ! isClosed()
|
||||
&& isTransactionFlushable()
|
||||
&& getHibernateFlushMode() != FlushMode.MANUAL;
|
||||
|
||||
try {
|
||||
if ( flush ) {
|
||||
if ( doFlush ) {
|
||||
managedFlush();
|
||||
}
|
||||
}
|
||||
|
@ -3243,7 +3016,7 @@ public final class SessionImpl
|
|||
|
||||
@Override
|
||||
public boolean isFlushBeforeCompletionEnabled() {
|
||||
return flushBeforeCompletionEnabled;
|
||||
return getHibernateFlushMode() != FlushMode.MANUAL;
|
||||
}
|
||||
|
||||
private static final AfterCompletionAction STANDARD_AFTER_COMPLETION_ACTION = (AfterCompletionAction) (successful, session) -> {
|
||||
|
@ -3254,13 +3027,10 @@ public final class SessionImpl
|
|||
public static class ManagedFlushCheckerStandardImpl implements ManagedFlushChecker {
|
||||
@Override
|
||||
public boolean shouldDoManagedFlush(SessionImplementor session) {
|
||||
final FlushMode flushMode = session.getHibernateFlushMode();
|
||||
final boolean isFlushModeNever = flushMode == FlushMode.MANUAL;
|
||||
return ( !isFlushModeNever &&
|
||||
!session.isFlushBeforeCompletionEnabled() ) ||
|
||||
!session.isClosed()
|
||||
&& !isFlushModeNever
|
||||
&& session.isFlushBeforeCompletionEnabled();
|
||||
if ( session.isClosed() ) {
|
||||
return false;
|
||||
}
|
||||
return session.getHibernateFlushMode() != FlushMode.MANUAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4001,7 +3771,7 @@ public final class SessionImpl
|
|||
}
|
||||
|
||||
private void joinTransaction(boolean explicitRequest) {
|
||||
if ( getTransactionType() != PersistenceUnitTransactionType.JTA ) {
|
||||
if ( !getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta() ) {
|
||||
if ( explicitRequest ) {
|
||||
log.callingJoinTransactionOnNonJtaEntityManager();
|
||||
}
|
||||
|
@ -4104,12 +3874,9 @@ public final class SessionImpl
|
|||
*
|
||||
* @throws IOException Indicates a general IO stream exception
|
||||
*/
|
||||
@Override
|
||||
protected void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
log.tracef( "Serializing Session [%s]", getSessionIdentifier() );
|
||||
|
||||
super.writeObject( oos );
|
||||
|
||||
oos.defaultWriteObject();
|
||||
|
||||
persistenceContext.serialize( oos );
|
||||
|
@ -4126,12 +3893,9 @@ public final class SessionImpl
|
|||
* @throws IOException Indicates a general IO stream exception
|
||||
* @throws ClassNotFoundException Indicates a class resolution issue
|
||||
*/
|
||||
@Override
|
||||
protected void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException, SQLException {
|
||||
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException, SQLException {
|
||||
log.tracef( "Deserializing Session [%s]", getSessionIdentifier() );
|
||||
|
||||
super.readObject( ois );
|
||||
|
||||
ois.defaultReadObject();
|
||||
|
||||
persistenceContext = StatefulPersistenceContext.deserialize( ois, this );
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.internal;
|
|||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||
import org.hibernate.engine.spi.ActionQueue;
|
||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
/**
|
||||
* An extension of SessionCreationOptions for cases where the Session to be created shares
|
||||
|
|
|
@ -425,12 +425,6 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableTransactionAutoJoin() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Object load(String entityName, Serializable identifier) {
|
||||
return null;
|
||||
|
|
|
@ -230,4 +230,12 @@ public interface DeprecationLogger extends BasicLogger {
|
|||
value = "Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA javax.persistence.criteria.CriteriaQuery instead"
|
||||
)
|
||||
void deprecatedLegacyCriteria();
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
id = 90000023,
|
||||
value = "Encountered use of deprecated Connection handling settings [hibernate.connection.acquisition_mode]" +
|
||||
"or [hibernate.connection.release_mode]; use [hibernate.connection.handling_mode] instead"
|
||||
)
|
||||
void logUseOfDeprecatedConnectionHandlingSettings();
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.jpa.internal;
|
||||
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.AfterCompletionAction;
|
||||
|
||||
|
@ -31,7 +29,7 @@ public class AfterCompletionActionLegacyJpaImpl implements AfterCompletionAction
|
|||
return;
|
||||
}
|
||||
|
||||
if ( !successful && session.getTransactionType() == PersistenceUnitTransactionType.JTA ) {
|
||||
if ( !successful && session.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta() ) {
|
||||
session.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,21 +21,21 @@ public interface LogicalConnection {
|
|||
* @return {@code true} if still open ({@link #close} has not been called yet); {@code false} if not open
|
||||
* (({@link #close} has been called).
|
||||
*/
|
||||
public boolean isOpen();
|
||||
boolean isOpen();
|
||||
|
||||
/**
|
||||
* Closes the JdbcSession, making it inactive and forcing release of any held resources
|
||||
*
|
||||
* @return Legacy :( Returns the JDBC Connection *if* the user passed in a Connection originally.
|
||||
*/
|
||||
public Connection close();
|
||||
Connection close();
|
||||
|
||||
/**
|
||||
* Is this JdbcSession currently physically connected (meaning does it currently hold a JDBC Connection)?
|
||||
*
|
||||
* @return {@code true} if the JdbcSession currently hold a JDBC Connection; {@code false} if it does not.
|
||||
*/
|
||||
public boolean isPhysicallyConnected();
|
||||
boolean isPhysicallyConnected();
|
||||
|
||||
/**
|
||||
* Provides access to the registry of JDBC resources associated with this LogicalConnection.
|
||||
|
@ -44,6 +44,6 @@ public interface LogicalConnection {
|
|||
*
|
||||
* @throws org.hibernate.ResourceClosedException if the LogicalConnection is closed
|
||||
*/
|
||||
public ResourceRegistry getResourceRegistry();
|
||||
ResourceRegistry getResourceRegistry();
|
||||
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ public interface ResourceRegistry {
|
|||
*
|
||||
* @return True if the registry does have registered resources; false otherwise.
|
||||
*/
|
||||
public boolean hasRegisteredResources();
|
||||
boolean hasRegisteredResources();
|
||||
|
||||
public void releaseResources();
|
||||
void releaseResources();
|
||||
|
||||
/**
|
||||
* Register a JDBC statement.
|
||||
|
@ -34,14 +34,14 @@ public interface ResourceRegistry {
|
|||
* @param cancelable Is the statement being registered capable of being cancelled? In other words,
|
||||
* should we register it to be the target of subsequent {@link #cancelLastQuery()} calls?
|
||||
*/
|
||||
public void register(Statement statement, boolean cancelable);
|
||||
void register(Statement statement, boolean cancelable);
|
||||
|
||||
/**
|
||||
* Release a previously registered statement.
|
||||
*
|
||||
* @param statement The statement to release.
|
||||
*/
|
||||
public void release(Statement statement);
|
||||
void release(Statement statement);
|
||||
|
||||
/**
|
||||
* Register a JDBC result set.
|
||||
|
@ -53,7 +53,7 @@ public interface ResourceRegistry {
|
|||
* @param resultSet The result set to register.
|
||||
* @param statement Statement from which {@link java.sql.ResultSet} has been generated.
|
||||
*/
|
||||
public void register(ResultSet resultSet, Statement statement);
|
||||
void register(ResultSet resultSet, Statement statement);
|
||||
|
||||
/**
|
||||
* Release a previously registered result set.
|
||||
|
@ -61,17 +61,17 @@ public interface ResourceRegistry {
|
|||
* @param resultSet The result set to release.
|
||||
* @param statement Statement from which {@link java.sql.ResultSet} has been generated.
|
||||
*/
|
||||
public void release(ResultSet resultSet, Statement statement);
|
||||
void release(ResultSet resultSet, Statement statement);
|
||||
|
||||
public void register(Blob blob);
|
||||
public void release(Blob blob);
|
||||
void register(Blob blob);
|
||||
void release(Blob blob);
|
||||
|
||||
public void register(Clob clob);
|
||||
public void release(Clob clob);
|
||||
void register(Clob clob);
|
||||
void release(Clob clob);
|
||||
|
||||
public void register(NClob nclob);
|
||||
public void release(NClob nclob);
|
||||
void register(NClob nclob);
|
||||
void release(NClob nclob);
|
||||
|
||||
public void cancelLastQuery();
|
||||
void cancelLastQuery();
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
package org.hibernate.resource.jdbc.spi;
|
||||
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
/**
|
||||
* Contract for something that controls a JdbcSessionContext. The name comes from the
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
*/
|
||||
package org.hibernate.resource.jdbc.spi;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
import static org.hibernate.ConnectionAcquisitionMode.AS_NEEDED;
|
||||
import static org.hibernate.ConnectionAcquisitionMode.IMMEDIATELY;
|
||||
|
@ -62,6 +65,23 @@ public enum PhysicalConnectionHandlingMode {
|
|||
return releaseMode;
|
||||
}
|
||||
|
||||
public static PhysicalConnectionHandlingMode interpret(Object setting) {
|
||||
if ( setting == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( setting instanceof PhysicalConnectionHandlingMode ) {
|
||||
return (PhysicalConnectionHandlingMode) setting;
|
||||
}
|
||||
|
||||
final String value = setting.toString();
|
||||
if ( StringHelper.isEmpty( value ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return PhysicalConnectionHandlingMode.valueOf( value.toUpperCase( Locale.ROOT ) );
|
||||
}
|
||||
|
||||
public static PhysicalConnectionHandlingMode interpret(
|
||||
ConnectionAcquisitionMode acquisitionMode,
|
||||
ConnectionReleaseMode releaseMode) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.resource.transaction;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
/**
|
||||
* Indicates a call to {@link TransactionCoordinator#explicitJoin()} that requires an
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
*/
|
||||
package org.hibernate.resource.transaction.backend.jdbc.internal;
|
||||
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransactionAccess;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +27,7 @@ public class JdbcResourceLocalTransactionCoordinatorBuilderImpl implements Trans
|
|||
public static final JdbcResourceLocalTransactionCoordinatorBuilderImpl INSTANCE = new JdbcResourceLocalTransactionCoordinatorBuilderImpl();
|
||||
|
||||
@Override
|
||||
public TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, TransactionCoordinatorOptions options) {
|
||||
public TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, Options options) {
|
||||
if ( owner instanceof JdbcResourceTransactionAccess ) {
|
||||
return new JdbcResourceLocalTransactionCoordinatorImpl( this, owner, (JdbcResourceTransactionAccess) owner );
|
||||
}
|
||||
|
@ -44,12 +43,7 @@ public class JdbcResourceLocalTransactionCoordinatorBuilderImpl implements Trans
|
|||
}
|
||||
|
||||
@Override
|
||||
public ConnectionReleaseMode getDefaultConnectionReleaseMode() {
|
||||
return ConnectionReleaseMode.AFTER_TRANSACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionAcquisitionMode getDefaultConnectionAcquisitionMode() {
|
||||
return ConnectionAcquisitionMode.AS_NEEDED;
|
||||
public PhysicalConnectionHandlingMode getDefaultConnectionHandlingMode() {
|
||||
return PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
|||
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.transaction.SynchronizationRegistry;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransaction;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransactionAccess;
|
||||
import org.hibernate.resource.transaction.internal.SynchronizationRegistryStandardImpl;
|
||||
import org.hibernate.resource.transaction.spi.SynchronizationRegistry;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
*/
|
||||
package org.hibernate.resource.transaction.backend.jta.internal;
|
||||
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +20,7 @@ public class JtaTransactionCoordinatorBuilderImpl implements TransactionCoordina
|
|||
public static final String SHORT_NAME = "jta";
|
||||
|
||||
@Override
|
||||
public TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, TransactionCoordinatorOptions options) {
|
||||
public TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, Options options) {
|
||||
return new JtaTransactionCoordinatorImpl(
|
||||
this,
|
||||
owner,
|
||||
|
@ -35,12 +34,8 @@ public class JtaTransactionCoordinatorBuilderImpl implements TransactionCoordina
|
|||
}
|
||||
|
||||
@Override
|
||||
public ConnectionReleaseMode getDefaultConnectionReleaseMode() {
|
||||
return ConnectionReleaseMode.AFTER_STATEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionAcquisitionMode getDefaultConnectionAcquisitionMode() {
|
||||
return ConnectionAcquisitionMode.AS_NEEDED;
|
||||
public PhysicalConnectionHandlingMode getDefaultConnectionHandlingMode() {
|
||||
// todo : I want to change this to PhysicalConnectionHandlingMode#IMMEDIATE_ACQUISITION_AND_HOLD
|
||||
return PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,6 @@ import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
|||
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.transaction.SynchronizationRegistry;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.TransactionRequiredForJoinException;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.RegisteredSynchronization;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackCoordinator;
|
||||
|
@ -31,6 +28,9 @@ import org.hibernate.resource.transaction.backend.jta.internal.synchronization.S
|
|||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackCoordinatorTrackingImpl;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackTarget;
|
||||
import org.hibernate.resource.transaction.internal.SynchronizationRegistryStandardImpl;
|
||||
import org.hibernate.resource.transaction.spi.SynchronizationRegistry;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
|
|
|
@ -16,7 +16,11 @@ import org.hibernate.engine.spi.SessionImplementor;
|
|||
* {@link javax.transaction.Synchronization} registered by Hibernate with the underlying JTA platform.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated (since 5.2) - probably getting removed in 5.2 as well. This was an SPI contract
|
||||
* intended for HEM that is no longer needed.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AfterCompletionAction extends Serializable {
|
||||
void doAction(boolean successful, SessionImplementor session);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,10 @@ import org.hibernate.engine.spi.SessionImplementor;
|
|||
* through the sister strategy {@link ExceptionMapper}.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated (since 5.2) no longer needed since integrating HEM into hibernate-core.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ManagedFlushChecker extends Serializable {
|
||||
/**
|
||||
* Check whether we should perform the managed flush
|
||||
|
|
|
@ -12,12 +12,10 @@ import org.hibernate.boot.registry.StandardServiceInitiator;
|
|||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* StandardServiceInitiator for initiating the TransactionCoordinatorBuilder service.
|
||||
*
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
/**
|
||||
* Defines the resource-level transaction capabilities of Hibernate, which revolves around the
|
||||
* {@link org.hibernate.resource.transaction.TransactionCoordinator} contract.
|
||||
* {@link org.hibernate.resource.transaction.spi.TransactionCoordinator} contract.
|
||||
* <p/>
|
||||
* TransactionCoordinator instances can be obtained from
|
||||
* {@link org.hibernate.resource.transaction.TransactionCoordinatorBuilder}, which is a Service
|
||||
* {@link org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder}, which is a Service
|
||||
* and available from the StandardServiceRegistry
|
||||
* <p/>
|
||||
* A few terms/concepts to keep in mind here...
|
||||
|
@ -20,7 +20,7 @@
|
|||
* The local transaction is the idea of transactionality exposed to the application (as
|
||||
* {@link org.hibernate.Transaction}) as a means to control the underlying transaction. That
|
||||
* control flows from the {@link org.hibernate.Transaction} into the TransactionCoordinator
|
||||
* through the {@link org.hibernate.resource.transaction.TransactionCoordinator.TransactionDriver} it exposes.
|
||||
* through the {@link org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver} it exposes.
|
||||
*
|
||||
* <h2>Physical transaction</h2>
|
||||
*
|
||||
|
@ -42,7 +42,7 @@
|
|||
* The Hibernate transaction api allows the application itself to register JTA Synchronization
|
||||
* objects with the TransactionCoordinator. These local Synchronizations work in all transaction
|
||||
* environments. See {@link org.hibernate.Transaction#registerSynchronization} and
|
||||
* {@link org.hibernate.resource.transaction.SynchronizationRegistry} for additional details.
|
||||
* {@link org.hibernate.resource.transaction.spi.SynchronizationRegistry} for additional details.
|
||||
*
|
||||
*/
|
||||
package org.hibernate.resource.transaction;
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.resource.transaction;
|
||||
package org.hibernate.resource.transaction.spi;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.transaction.Synchronization;
|
||||
|
||||
import org.hibernate.resource.transaction.NullSynchronizationException;
|
||||
|
||||
/**
|
||||
* Manages a registry of (local) JTA {@link Synchronization} instances
|
||||
*
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.resource.transaction.spi;
|
||||
|
||||
import org.hibernate.resource.transaction.SynchronizationRegistry;
|
||||
|
||||
/**
|
||||
* SPI contract for SynchronizationRegistry implementors.
|
||||
*
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.resource.transaction;
|
||||
package org.hibernate.resource.transaction.spi;
|
||||
|
||||
import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
||||
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
/**
|
||||
* Models the coordination of all transaction related flows.
|
|
@ -4,13 +4,12 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.resource.transaction;
|
||||
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner;
|
||||
import org.hibernate.service.Service;
|
||||
package org.hibernate.resource.transaction.spi;
|
||||
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.service.Service;
|
||||
|
||||
/**
|
||||
* Builder for TransactionCoordinator instances
|
||||
|
@ -21,7 +20,7 @@ public interface TransactionCoordinatorBuilder extends Service {
|
|||
/**
|
||||
* Access to options to are specific to each TransactionCoordinator instance
|
||||
*/
|
||||
static interface TransactionCoordinatorOptions {
|
||||
static interface Options {
|
||||
/**
|
||||
* Indicates whether an active transaction should be automatically joined. Only relevant
|
||||
* for JTA-based TransactionCoordinator instances.
|
||||
|
@ -32,11 +31,25 @@ public interface TransactionCoordinatorBuilder extends Service {
|
|||
boolean shouldAutoJoinTransaction();
|
||||
}
|
||||
|
||||
TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, TransactionCoordinatorOptions options);
|
||||
TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, Options options);
|
||||
|
||||
boolean isJta();
|
||||
|
||||
ConnectionReleaseMode getDefaultConnectionReleaseMode();
|
||||
PhysicalConnectionHandlingMode getDefaultConnectionHandlingMode();
|
||||
|
||||
ConnectionAcquisitionMode getDefaultConnectionAcquisitionMode();
|
||||
/**
|
||||
* @deprecated (since 5.2) Use {@link #getDefaultConnectionHandlingMode} instead
|
||||
*/
|
||||
@Deprecated
|
||||
default ConnectionAcquisitionMode getDefaultConnectionAcquisitionMode() {
|
||||
return getDefaultConnectionHandlingMode().getAcquisitionMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated (since 5.2) Use {@link #getDefaultConnectionHandlingMode} instead
|
||||
*/
|
||||
@Deprecated
|
||||
default ConnectionReleaseMode getDefaultConnectionReleaseMode() {
|
||||
return getDefaultConnectionHandlingMode().getReleaseMode();
|
||||
}
|
||||
}
|
|
@ -24,7 +24,9 @@ import org.hibernate.testing.RequiresDialect;
|
|||
public class BasicConnectionProviderTest extends ConnectionManagementTestCase {
|
||||
@Override
|
||||
protected Session getSessionUnderTest() {
|
||||
return openSession();
|
||||
Session session = openSession();
|
||||
session.beginTransaction();
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase
|
|||
long initialCount = sessionFactory().getStatistics().getSessionCloseCount();
|
||||
session.getTransaction().commit();
|
||||
long subsequentCount = sessionFactory().getStatistics().getSessionCloseCount();
|
||||
assertEquals( "Session still open afterQuery commit", initialCount + 1, subsequentCount );
|
||||
assertEquals( "Session still open after commit", initialCount + 1, subsequentCount );
|
||||
// also make sure it was cleaned up from the internal ThreadLocal...
|
||||
assertFalse( "session still bound to internal ThreadLocal", TestableThreadLocalContext.hasBind() );
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase
|
|||
Session session = sessionFactory().getCurrentSession();
|
||||
session.beginTransaction();
|
||||
session.getTransaction().commit();
|
||||
assertFalse( "session open afterQuery txn completion", session.isOpen() );
|
||||
assertFalse( "session open after txn completion", session.isOpen() );
|
||||
assertFalse( "session still bound afterQuery txn completion", TestableThreadLocalContext.isSessionBound( session ) );
|
||||
|
||||
Session session2 = sessionFactory().getCurrentSession();
|
||||
|
|
|
@ -6,11 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.test.jdbc.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.Statement;
|
||||
|
||||
|
@ -28,13 +23,16 @@ import org.hibernate.engine.spi.SessionImplementor;
|
|||
import org.hibernate.jdbc.Expectation;
|
||||
import org.hibernate.jdbc.Expectations;
|
||||
import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
|
||||
import org.hibernate.test.common.JournalingBatchObserver;
|
||||
import org.hibernate.test.common.JournalingTransactionObserver;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.test.common.JournalingBatchObserver;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
* @author Brett Meyer
|
||||
|
|
|
@ -8,13 +8,12 @@ package org.hibernate.test.resource.transaction;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.internal.TransactionCoordinatorBuilderInitiator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -6,13 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.test.resource.transaction.jdbc;
|
||||
|
||||
import javax.transaction.Synchronization;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.TransactionException;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
import org.hibernate.test.resource.common.SynchronizationCollectorImpl;
|
||||
|
@ -34,7 +31,7 @@ public class BasicJdbcTransactionTests {
|
|||
|
||||
final TransactionCoordinator transactionCoordinator = transactionCoordinatorBuilder.buildTransactionCoordinator(
|
||||
owner,
|
||||
new TransactionCoordinatorBuilder.TransactionCoordinatorOptions() {
|
||||
new TransactionCoordinatorBuilder.Options() {
|
||||
@Override
|
||||
public boolean shouldAutoJoinTransaction() {
|
||||
return false;
|
||||
|
@ -66,7 +63,7 @@ public class BasicJdbcTransactionTests {
|
|||
|
||||
final TransactionCoordinator transactionCoordinator = transactionCoordinatorBuilder.buildTransactionCoordinator(
|
||||
owner,
|
||||
new TransactionCoordinatorBuilder.TransactionCoordinatorOptions() {
|
||||
new TransactionCoordinatorBuilder.Options() {
|
||||
@Override
|
||||
public boolean shouldAutoJoinTransaction() {
|
||||
return false;
|
||||
|
@ -101,7 +98,7 @@ public class BasicJdbcTransactionTests {
|
|||
|
||||
final TransactionCoordinator transactionCoordinator = transactionCoordinatorBuilder.buildTransactionCoordinator(
|
||||
owner,
|
||||
new TransactionCoordinatorBuilder.TransactionCoordinatorOptions() {
|
||||
new TransactionCoordinatorBuilder.Options() {
|
||||
@Override
|
||||
public boolean shouldAutoJoinTransaction() {
|
||||
return false;
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.test.resource.transaction.jta;
|
||||
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan.access;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.hibernate.cache.infinispan.util.FutureUpdate;
|
||||
import org.hibernate.cache.infinispan.util.InfinispanMessageLogger;
|
||||
import org.hibernate.cache.infinispan.util.InvocationAfterCompletion;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.infinispan.AdvancedCache;
|
||||
|
||||
/**
|
||||
* @author Radim Vansa <rvansa@redhat.com>
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.hibernate.cache.infinispan.util.VersionedEntry;
|
|||
import org.hibernate.cache.spi.access.SoftLock;
|
||||
import org.hibernate.cache.spi.entry.CacheEntry;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.configuration.cache.Configuration;
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.hibernate.cache.CacheException;
|
|||
import org.hibernate.cache.infinispan.impl.BaseRegion;
|
||||
import org.hibernate.cache.spi.access.SoftLock;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.hibernate.cache.infinispan.util.CacheCommandInitializer;
|
|||
import org.hibernate.cache.infinispan.util.InfinispanMessageLogger;
|
||||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.configuration.cache.CacheMode;
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan.access;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
|
||||
import org.hibernate.cache.infinispan.util.InvocationAfterCompletion;
|
||||
import org.hibernate.cache.infinispan.util.VersionedEntry;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.infinispan.AdvancedCache;
|
||||
|
||||
/**
|
||||
* @author Radim Vansa <rvansa@redhat.com>
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.hibernate.cache.infinispan.util.Tombstone;
|
|||
import org.hibernate.cache.infinispan.util.TombstoneUpdate;
|
||||
import org.hibernate.cache.spi.access.SoftLock;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.configuration.cache.Configuration;
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan.access;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
|
||||
import org.hibernate.cache.infinispan.util.InvocationAfterCompletion;
|
||||
import org.hibernate.cache.infinispan.util.Tombstone;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.infinispan.AdvancedCache;
|
||||
|
||||
/**
|
||||
* @author Radim Vansa <rvansa@redhat.com>
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan.query;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import javax.transaction.Transaction;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
|
@ -17,17 +21,13 @@ import org.hibernate.cache.infinispan.util.InfinispanMessageLogger;
|
|||
import org.hibernate.cache.infinispan.util.InvocationAfterCompletion;
|
||||
import org.hibernate.cache.spi.QueryResultsRegion;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.configuration.cache.TransactionConfiguration;
|
||||
import org.infinispan.context.Flag;
|
||||
import org.infinispan.transaction.TransactionMode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Region for caching query results.
|
||||
*
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan.util;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.jdbc.WorkExecutor;
|
||||
import org.hibernate.jdbc.WorkExecutorVisitable;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.infinispan.AdvancedCache;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.Synchronization;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.jdbc.WorkExecutor;
|
||||
import org.hibernate.jdbc.WorkExecutorVisitable;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import org.infinispan.AdvancedCache;
|
||||
|
||||
/**
|
||||
* @author Radim Vansa <rvansa@redhat.com>
|
||||
|
|
|
@ -25,9 +25,9 @@ import org.hibernate.engine.transaction.internal.TransactionImpl;
|
|||
import org.hibernate.internal.util.compare.ComparableComparator;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransactionAccess;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
|
|
|
@ -24,24 +24,24 @@ import org.hibernate.mapping.PersistentClass;
|
|||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.RootClass;
|
||||
import org.hibernate.mapping.SimpleValue;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
|
||||
import org.hibernate.testing.BeforeClassOnce;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.testing.junit4.CustomParameterized;
|
||||
import org.hibernate.test.cache.infinispan.tm.JtaPlatformImpl;
|
||||
import org.hibernate.test.cache.infinispan.tm.XaConnectionProvider;
|
||||
import org.hibernate.test.cache.infinispan.util.InfinispanTestingSetup;
|
||||
import org.hibernate.test.cache.infinispan.util.TestInfinispanRegionFactory;
|
||||
import org.hibernate.test.cache.infinispan.util.TxUtil;
|
||||
import org.hibernate.testing.BeforeClassOnce;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.test.cache.infinispan.tm.JtaPlatformImpl;
|
||||
|
||||
import org.hibernate.testing.junit4.CustomParameterized;
|
||||
import org.infinispan.configuration.cache.CacheMode;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import org.infinispan.configuration.cache.CacheMode;
|
||||
|
||||
/**
|
||||
* @author Galder Zamarreño
|
||||
* @since 3.5
|
||||
|
|
|
@ -18,12 +18,11 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
|||
import org.hibernate.cache.infinispan.util.InfinispanMessageLogger;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
|
||||
import org.hibernate.test.cache.infinispan.functional.AbstractFunctionalTest;
|
||||
import org.hibernate.test.cache.infinispan.util.InfinispanTestingSetup;
|
||||
|
||||
import org.hibernate.test.cache.infinispan.util.TxUtil;
|
||||
import org.junit.ClassRule;
|
||||
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
package org.hibernate.test.cache.infinispan.util;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import javax.transaction.RollbackException;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.Synchronization;
|
||||
import javax.transaction.SystemException;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||
import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
||||
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
||||
import org.hibernate.resource.transaction.SynchronizationRegistry;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaIsolationDelegate;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.StatusTranslator;
|
||||
import org.hibernate.resource.transaction.spi.SynchronizationRegistry;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
import org.infinispan.transaction.tm.BatchModeTransactionManager;
|
||||
import org.infinispan.transaction.tm.DummyTransaction;
|
||||
|
||||
import javax.transaction.RollbackException;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.Synchronization;
|
||||
import javax.transaction.SystemException;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.hibernate.internal.util.StringHelper;
|
|||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.jdbc.AbstractReturningWork;
|
||||
import org.hibernate.jdbc.Work;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
import org.hibernate.testing.AfterClassOnce;
|
||||
import org.hibernate.testing.BeforeClassOnce;
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.hibernate.mapping.PersistentClass;
|
|||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.RootClass;
|
||||
import org.hibernate.mapping.SimpleValue;
|
||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.type.BlobType;
|
||||
import org.hibernate.type.ClobType;
|
||||
import org.hibernate.type.NClobType;
|
||||
|
|
Loading…
Reference in New Issue