org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode Java Examples
The following examples show how to use
org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceLocalReleaseAfterStatementConfiguration.java From high-performance-java-persistence with Apache License 2.0 | 6 votes |
protected Properties additionalProperties() { Properties properties = new Properties(); properties.setProperty("hibernate.dialect", hibernateDialect); properties.setProperty("hibernate.hbm2ddl.auto", "create-drop"); properties.put( "hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList( new ClassImportIntegrator(Arrays.asList(PostDTO.class)) ) ); properties.put( AvailableSettings.CONNECTION_HANDLING, //PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION ); return properties; }
Example #2
Source File: ConnectionStatisticsTest.java From high-performance-java-persistence with Apache License 2.0 | 5 votes |
protected void additionalProperties(Properties properties) { DataSource actualDataSource = (DataSource) properties .get(AvailableSettings.DATASOURCE); properties.put( AvailableSettings.CONNECTION_PROVIDER, new ThreadLocalDatasourceConnectionProvider(actualDataSource) ); properties.put( AvailableSettings.CONNECTION_HANDLING, PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT ); properties.put( AvailableSettings.CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT, Boolean.TRUE.toString() ); properties.put( AvailableSettings.GENERATE_STATISTICS, Boolean.TRUE.toString() ); properties.put( StatisticsInitiator.STATS_BUILDER, TransactionStatisticsFactory.class.getName() ); }
Example #3
Source File: SessionFactoryOptionsBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
public void applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { if ( this.connectionHandlingMode == null ) { this.connectionHandlingMode = PhysicalConnectionHandlingMode.interpret( ConnectionAcquisitionMode.AS_NEEDED, connectionReleaseMode ); } else { this.connectionHandlingMode = PhysicalConnectionHandlingMode.interpret( this.connectionHandlingMode.getAcquisitionMode(), connectionReleaseMode ); } }
Example #4
Source File: LogicalConnectionManagedImpl.java From lams with GNU General Public License v2.0 | 5 votes |
private PhysicalConnectionHandlingMode determineConnectionHandlingMode( PhysicalConnectionHandlingMode connectionHandlingMode, JdbcConnectionAccess jdbcConnectionAccess) { if ( connectionHandlingMode.getReleaseMode() == ConnectionReleaseMode.AFTER_STATEMENT && !jdbcConnectionAccess.supportsAggressiveRelease() ) { return PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION; } return connectionHandlingMode; }
Example #5
Source File: SessionFactoryOptionsBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") 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 ); }
Example #6
Source File: SessionFactoryOptionsBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") 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(); }
Example #7
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public Session openTemporarySession() throws HibernateException { return withOptions() .autoClose( false ) .flushMode( FlushMode.MANUAL ) .connectionHandlingMode( PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT ) .openSession(); }
Example #8
Source File: HibernateTransactionManager.java From micronaut-data with Apache License 2.0 | 5 votes |
/** * Return whether the given Hibernate Session will always hold the same * JDBC Connection. This is used to check whether the transaction manager * can safely prepare and clean up the JDBC Connection used for a transaction. * <p>The default implementation checks the Session's connection release mode * to be "on_close". * @param session the Hibernate Session to check * @see ConnectionReleaseMode#ON_CLOSE * @return Whether the same connection is needed for the whole session */ protected boolean isSameConnectionForEntireSession(Session session) { if (!(session instanceof SessionImplementor)) { // The best we can do is to assume we're safe. return true; } PhysicalConnectionHandlingMode releaseMode = ((SessionImplementor) session).getJdbcCoordinator() .getLogicalConnection() .getConnectionHandlingMode(); return PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_HOLD.equals(releaseMode); }
Example #9
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() { return connectionHandlingMode; }
Example #10
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode) { this.optionsBuilder.applyConnectionHandlingMode( connectionHandlingMode ); return this; }
Example #11
Source File: SessionFactoryOptionsBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
public void applyConnectionHandlingMode(PhysicalConnectionHandlingMode mode) { this.connectionHandlingMode = mode; }
Example #12
Source File: SessionFactoryOptionsBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() { return connectionHandlingMode; }
Example #13
Source File: AbstractDelegatingSessionFactoryBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public T applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode) { delegate.applyConnectionHandlingMode( connectionHandlingMode ); return getThis(); }
Example #14
Source File: AbstractDelegatingSessionFactoryOptions.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() { return delegate.getPhysicalConnectionHandlingMode(); }
Example #15
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() { return null; }
Example #16
Source File: JdbcSessionContextImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() { return connectionHandlingMode; }
Example #17
Source File: AbstractDelegatingSharedSessionBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public T connectionHandlingMode(PhysicalConnectionHandlingMode mode) { delegate.connectionHandlingMode( mode ); return getThis(); }
Example #18
Source File: AbstractDelegatingSessionBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public T connectionHandlingMode(PhysicalConnectionHandlingMode mode) { delegate.connectionHandlingMode( mode ); return getThis(); }
Example #19
Source File: LogicalConnectionManagedImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getConnectionHandlingMode() { return connectionHandlingMode; }
Example #20
Source File: LogicalConnectionProvidedImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getConnectionHandlingMode() { return PhysicalConnectionHandlingMode.IMMEDIATE_ACQUISITION_AND_HOLD; }
Example #21
Source File: JtaTransactionCoordinatorBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getDefaultConnectionHandlingMode() { // todo : I want to change this to PhysicalConnectionHandlingMode#IMMEDIATE_ACQUISITION_AND_HOLD return PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT; }
Example #22
Source File: JdbcResourceLocalTransactionCoordinatorBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PhysicalConnectionHandlingMode getDefaultConnectionHandlingMode() { return PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION; }
Example #23
Source File: SessionFactoryBuilder.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Apply the specified handling mode for JDBC connections * * @param connectionHandlingMode The handling mode to apply * * @return {@code this}, for method chaining * * @see org.hibernate.cfg.AvailableSettings#ACQUIRE_CONNECTIONS * @see org.hibernate.cfg.AvailableSettings#RELEASE_CONNECTIONS * @see org.hibernate.ConnectionAcquisitionMode * @see ConnectionReleaseMode */ SessionFactoryBuilder applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode);
Example #24
Source File: JdbcCoordinator.java From lams with GNU General Public License v2.0 | 2 votes |
/** * The mode for physical handling of the JDBC Connection * * @return The JDBC Connection handlng mode * * @deprecated (since 5.2) access via {@link #getLogicalConnection} instead */ @Deprecated default PhysicalConnectionHandlingMode getConnectionHandlingMode() { return getLogicalConnection().getConnectionHandlingMode(); }
Example #25
Source File: SessionBuilder.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Signifies that the connection release mode from the original session should be used to create the new session. * * @param mode The connection handling mode to use. * * @return {@code this}, for method chaining */ T connectionHandlingMode(PhysicalConnectionHandlingMode mode);
Example #26
Source File: SessionCreationOptions.java From lams with GNU General Public License v2.0 | votes |
PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode();
Example #27
Source File: SessionFactoryOptions.java From lams with GNU General Public License v2.0 | votes |
PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode();
Example #28
Source File: TransactionCoordinatorBuilder.java From lams with GNU General Public License v2.0 | votes |
PhysicalConnectionHandlingMode getDefaultConnectionHandlingMode();