Java Code Examples for org.hibernate.boot.spi.SessionFactoryBuilderImplementor

The following examples show how to use org.hibernate.boot.spi.SessionFactoryBuilderImplementor. 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: mPaaS   Source File: HibernateMetadataExtractor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SessionFactoryBuilder getSessionFactoryBuilder(
        MetadataImplementor metadata,
        SessionFactoryBuilderImplementor defaultBuilder) {
    List<String> handled = new ArrayList<>();
    for (PersistentClass entity : metadata.getEntityBindings()) {
        bind(entity, handled);
    }
    return null;
}
 
Example 2
@Override
public EntityManagerFactory build() {
    final MetadataImpl metadata = (MetadataImpl) metadata();
    final StandardServiceRegistry standardServiceRegistry = getStandardServiceRegistry();
    final SessionFactoryBuilderImpl defaultBuilder = new SessionFactoryBuilderImpl( metadata, metadata.getBootstrapContext() );
    final SessionFactoryBuilderImplementor reactiveSessionFactoryBuilder = new ReactiveSessionFactoryBuilder( metadata, defaultBuilder );
    populateSfBuilder( reactiveSessionFactoryBuilder, standardServiceRegistry );

    try {
        return reactiveSessionFactoryBuilder.build();
    }
    catch (Exception e) {
        throw persistenceException( "Unable to build Hibernate SessionFactory", e );
    }
}
 
Example 3
public ReactiveSessionFactoryBuilder(MetadataImplementor metadata, SessionFactoryBuilderImplementor delegate) {
	super( delegate );

	this.metadata = metadata;
	this.delegate = delegate;
}
 
Example 4
@Override
public SessionFactoryBuilderImplementor createSessionFactoryBuilder(final MetadataImpl metadata, final BootstrapContext bootstrapContext) {
	final SessionFactoryBuilderImpl defaultBuilder = new SessionFactoryBuilderImpl( metadata, bootstrapContext );
	final SessionFactoryBuilderImplementor reactiveSessionFactoryBuilder = new ReactiveSessionFactoryBuilder( metadata, defaultBuilder );
	return reactiveSessionFactoryBuilder;
}
 
Example 5
@Override
public SessionFactoryBuilder getSessionFactoryBuilder(MetadataImplementor metadata,
													  SessionFactoryBuilderImplementor defaultBuilder) {
	return new ReactiveSessionFactoryBuilder( metadata, defaultBuilder );
}
 
Example 6
protected void populate(SessionFactoryBuilder sfBuilder, StandardServiceRegistry ssr) {

		final StrategySelector strategySelector = ssr.getService( StrategySelector.class );

//		// Locate and apply the requested SessionFactory-level interceptor (if one)
//		final Object sessionFactoryInterceptorSetting = configurationValues.remove( org.hibernate.cfg.AvailableSettings.INTERCEPTOR );
//		if ( sessionFactoryInterceptorSetting != null ) {
//			final Interceptor sessionFactoryInterceptor =
//					strategySelector.resolveStrategy( Interceptor.class, sessionFactoryInterceptorSetting );
//			sfBuilder.applyInterceptor( sessionFactoryInterceptor );
//		}

		// will use user override value or default to false if not supplied to follow JPA spec.
		final boolean jtaTransactionAccessEnabled = readBooleanConfigurationValue( AvailableSettings.ALLOW_JTA_TRANSACTION_ACCESS );
		if ( !jtaTransactionAccessEnabled ) {
			( ( SessionFactoryBuilderImplementor ) sfBuilder ).disableJtaTransactionAccess();
		}

		final boolean allowRefreshDetachedEntity = readBooleanConfigurationValue( org.hibernate.cfg.AvailableSettings.ALLOW_REFRESH_DETACHED_ENTITY );
		if ( !allowRefreshDetachedEntity ) {
			( (SessionFactoryBuilderImplementor) sfBuilder ).disableRefreshDetachedEntity();
		}

		// Locate and apply any requested SessionFactoryObserver
		final Object sessionFactoryObserverSetting = configurationValues.remove( AvailableSettings.SESSION_FACTORY_OBSERVER );
		if ( sessionFactoryObserverSetting != null ) {
			final SessionFactoryObserver suppliedSessionFactoryObserver =
					strategySelector.resolveStrategy( SessionFactoryObserver.class, sessionFactoryObserverSetting );
			sfBuilder.addSessionFactoryObservers( suppliedSessionFactoryObserver );
		}

		sfBuilder.addSessionFactoryObservers( ServiceRegistryCloser.INSTANCE );

		sfBuilder.applyEntityNotFoundDelegate( JpaEntityNotFoundDelegate.INSTANCE );

		if ( this.validatorFactory != null ) {
			sfBuilder.applyValidatorFactory( validatorFactory );
		}
		if ( this.cdiBeanManager != null ) {
			sfBuilder.applyBeanManager( cdiBeanManager );
		}
	}
 
Example 7
@Override
public SessionFactoryBuilder getSessionFactoryBuilder( MetadataImplementor metadataImplementor, SessionFactoryBuilderImplementor defaultBuilder )
{
    HibernateMetadata.metadataImplementor.set( metadataImplementor );
    return defaultBuilder;
}