org.hibernate.boot.spi.SessionFactoryBuilderImplementor Java Examples

The following examples show how to use org.hibernate.boot.spi.SessionFactoryBuilderImplementor. 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: HibernateMetadataExtractor.java    From mPaaS with 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
Source File: ReactiveEntityManagerFactoryBuilder.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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
Source File: ReactiveSessionFactoryBuilder.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ReactiveSessionFactoryBuilder(MetadataImplementor metadata, SessionFactoryBuilderImplementor delegate) {
	super( delegate );

	this.metadata = metadata;
	this.delegate = delegate;
}
 
Example #4
Source File: ReactiveSessionFactoryBuilderService.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
@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
Source File: ReactiveSessionFactoryBuilderFactory.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public SessionFactoryBuilder getSessionFactoryBuilder(MetadataImplementor metadata,
													  SessionFactoryBuilderImplementor defaultBuilder) {
	return new ReactiveSessionFactoryBuilder( metadata, defaultBuilder );
}
 
Example #6
Source File: EntityManagerFactoryBuilderImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
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
Source File: HibernateMetadata.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public SessionFactoryBuilder getSessionFactoryBuilder( MetadataImplementor metadataImplementor, SessionFactoryBuilderImplementor defaultBuilder )
{
    HibernateMetadata.metadataImplementor.set( metadataImplementor );
    return defaultBuilder;
}