Java Code Examples for org.hibernate.resource.jdbc.spi.StatementInspector

The following examples show how to use org.hibernate.resource.jdbc.spi.StatementInspector. These examples are extracted from open source projects. 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 Project: lams   Source File: JdbcSessionContextImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public JdbcSessionContextImpl(SharedSessionContractImplementor session, StatementInspector statementInspector) {
	this.sessionFactory = session.getFactory();
	this.statementInspector = statementInspector;
	this.connectionHandlingMode = settings().getPhysicalConnectionHandlingMode();
	this.serviceRegistry = sessionFactory.getServiceRegistry();
	this.jdbcObserver = new JdbcObserverImpl( session );

	if ( this.statementInspector == null ) {
		throw new IllegalArgumentException( "StatementInspector cannot be null" );
	}
}
 
Example 2
private StatementInspector interpret(StatementInspector statementInspector) {
	if ( statementInspector == null ) {
		// If there is no StatementInspector specified, map to the call
		//		to the (deprecated) Interceptor #onPrepareStatement method
		return (StatementInspector) interceptor::onPrepareStatement;
	}
	return statementInspector;
}
 
Example 3
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException, SQLException {
	if ( log.isTraceEnabled() ) {
		log.trace( "Deserializing " + getClass().getSimpleName() );
	}

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Step 1 :: read back non-transient state...
	ois.defaultReadObject();
	sessionEventsManager = new SessionEventListenerManagerImpl();

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Step 2 :: read back transient state...
	//		-- see above

	factory = SessionFactoryImpl.deserialize( ois );
	jdbcSessionContext = new JdbcSessionContextImpl( this, (StatementInspector) ois.readObject() );
	jdbcCoordinator = JdbcCoordinatorImpl.deserialize( ois, this );

	cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );

	transactionCoordinator = factory.getServiceRegistry()
			.getService( TransactionCoordinatorBuilder.class )
			.buildTransactionCoordinator( jdbcCoordinator, this );

	entityNameResolver = new CoordinatingEntityNameResolver( factory, interceptor );
	exceptionConverter = new ExceptionConverterImpl( this );
}
 
Example 4
Source Project: lams   Source File: JdbcSessionContextImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public StatementInspector getStatementInspector() {
	return statementInspector;
}
 
Example 5
Source Project: lams   Source File: SessionFactoryImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public StatementInspector getStatementInspector() {
	return statementInspector;
}
 
Example 6
Source Project: lams   Source File: SessionFactoryImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public StatementInspector getStatementInspector() {
	return null;
}
 
Example 7
public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options) {
	this.factory = factory;
	this.cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );

	this.flushMode = options.getInitialSessionFlushMode();

	this.tenantIdentifier = options.getTenantIdentifier();
	if ( MultiTenancyStrategy.NONE == factory.getSettings().getMultiTenancyStrategy() ) {
		if ( tenantIdentifier != null ) {
			throw new HibernateException( "SessionFactory was not configured for multi-tenancy" );
		}
	}
	else {
		if ( tenantIdentifier == null ) {
			throw new HibernateException( "SessionFactory configured for multi-tenancy, but no tenant identifier specified" );
		}
	}

	this.interceptor = interpret( options.getInterceptor() );
	this.jdbcTimeZone = options.getJdbcTimeZone();

	final StatementInspector statementInspector = interpret( options.getStatementInspector() );
	this.jdbcSessionContext = new JdbcSessionContextImpl( this, statementInspector );

	this.entityNameResolver = new CoordinatingEntityNameResolver( factory, interceptor );

	if ( options instanceof SharedSessionCreationOptions && ( (SharedSessionCreationOptions) options ).isTransactionCoordinatorShared() ) {
		if ( options.getConnection() != null ) {
			throw new SessionException( "Cannot simultaneously share transaction context and specify connection" );
		}

		this.isTransactionCoordinatorShared = true;

		final SharedSessionCreationOptions sharedOptions = (SharedSessionCreationOptions) options;
		this.transactionCoordinator = sharedOptions.getTransactionCoordinator();
		this.jdbcCoordinator = sharedOptions.getJdbcCoordinator();

		// todo : "wrap" the transaction to no-op cmmit/rollback attempts?
		this.currentHibernateTransaction = sharedOptions.getTransaction();

		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(
					"Session creation specified 'PhysicalConnectionHandlingMode which is invalid in conjunction " +
							"with sharing JDBC connection between sessions; ignoring"
			);
		}

		addSharedSessionTransactionObserver( transactionCoordinator );
	}
	else {
		this.isTransactionCoordinatorShared = false;
		this.autoJoinTransactions = options.shouldAutoJoinTransactions();

		this.jdbcCoordinator = new JdbcCoordinatorImpl( options.getConnection(), this );
		this.transactionCoordinator = factory.getServiceRegistry()
				.getService( TransactionCoordinatorBuilder.class )
				.buildTransactionCoordinator( jdbcCoordinator, this );
	}
	exceptionConverter = new ExceptionConverterImpl( this );
}
 
Example 8
@Override
public StatementInspector getStatementInspector() {
	return delegate.getStatementInspector();
}
 
Example 9
@Override
public T applyStatementInspector(StatementInspector statementInspector) {
	delegate.applyStatementInspector( statementInspector );
	return getThis();
}
 
Example 10
@Override
public StatementInspector getStatementInspector() {
	return statementInspector;
}
 
Example 11
public void applyStatementInspector(StatementInspector statementInspector) {
	this.statementInspector = statementInspector;
}
 
Example 12
@Override
public SessionFactoryBuilder applyStatementInspector(StatementInspector statementInspector) {
	this.optionsBuilder.applyStatementInspector( statementInspector );
	return this;
}
 
Example 13
Source Project: lams   Source File: SessionFactoryBuilder.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Names a StatementInspector to be applied to the SessionFactory, which in turn means it will be used by all
 * Sessions unless one is explicitly specified in {@link org.hibernate.SessionBuilder#statementInspector}
 *
 * @param statementInspector The StatementInspector
 *
 * @return {@code this}, for method chaining
 *
 * @see org.hibernate.cfg.AvailableSettings#STATEMENT_INSPECTOR
 */
SessionFactoryBuilder applyStatementInspector(StatementInspector statementInspector);
 
Example 14
StatementInspector getStatementInspector(); 
Example 15
StatementInspector getStatementInspector();