org.hibernate.boot.SessionFactoryBuilder Java Examples
The following examples show how to use
org.hibernate.boot.SessionFactoryBuilder.
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: EntityManagerFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void generateSchema() { // This seems overkill, but building the SF is necessary to get the Integrators to kick in. // Metamodel will clean this up... try { SessionFactoryBuilder sfBuilder = metadata().getSessionFactoryBuilder(); populate( sfBuilder, standardServiceRegistry ); SchemaManagementToolCoordinator.process( metadata, standardServiceRegistry, configurationValues, DelayedDropRegistryNotAvailableImpl.INSTANCE ); } catch (Exception e) { throw persistenceException( "Error performing schema management", e ); } // release this builder cancel(); }
Example #2
Source File: ReactiveSessionFactoryBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public <T extends SessionFactoryBuilder> T unwrap(Class<T> type) { if ( type.isAssignableFrom( getClass() ) ) { return type.cast( this ); } else { return delegate.unwrap( type ); } }
Example #3
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public SessionFactoryBuilder applyEntityTuplizer( EntityMode entityMode, Class<? extends EntityTuplizer> tuplizerClass) { this.optionsBuilder.applyEntityTuplizer( entityMode, tuplizerClass ); return this; }
Example #4
Source File: EntityManagerFactoryBean.java From micronaut-sql with Apache License 2.0 | 5 votes |
/** * Builds the actual {@link SessionFactory} from the builder. * * @param sessionFactoryBuilder The {@link SessionFactoryBuilder} * @return The {@link SessionFactory} */ @Context @Requires(beans = SessionFactoryBuilder.class) @Bean(preDestroy = "close") @EachBean(SessionFactoryBuilder.class) protected SessionFactory hibernateSessionFactory(SessionFactoryBuilder sessionFactoryBuilder) { return sessionFactoryBuilder.build(); }
Example #5
Source File: HibernateMetadataExtractor.java From mPaaS with Apache License 2.0 | 5 votes |
@Override public SessionFactoryBuilder getSessionFactoryBuilder( MetadataImplementor metadata, SessionFactoryBuilderImplementor defaultBuilder) { List<String> handled = new ArrayList<>(); for (PersistentClass entity : metadata.getEntityBindings()) { bind(entity, handled); } return null; }
Example #6
Source File: EntityManagerFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public EntityManagerFactory build() { SessionFactoryBuilder sfBuilder = metadata().getSessionFactoryBuilder(); populate( sfBuilder, standardServiceRegistry ); try { return sfBuilder.build(); } catch (Exception e) { throw persistenceException( "Unable to build Hibernate SessionFactory", e ); } }
Example #7
Source File: InFlightMetadataCollectorImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public SessionFactoryBuilder getSessionFactoryBuilder() { throw new UnsupportedOperationException( "You should not be building a SessionFactory from an in-flight metadata collector; and of course " + "we should better segment this in the API :)" ); }
Example #8
Source File: HibernateLifecycleUtil.java From tutorials with MIT License | 5 votes |
private static SessionFactoryBuilder getSessionFactoryBuilder(ServiceRegistry serviceRegistry) { MetadataSources metadataSources = new MetadataSources(serviceRegistry); metadataSources.addAnnotatedClass(FootballPlayer.class); Metadata metadata = metadataSources.buildMetadata(); return metadata.getSessionFactoryBuilder(); }
Example #9
Source File: HibernateUtil.java From tutorials with MIT License | 5 votes |
private static SessionFactoryBuilder getSessionFactoryBuilder(ServiceRegistry serviceRegistry) { MetadataSources metadataSources = new MetadataSources(serviceRegistry); metadataSources.addPackage("com.baeldung.hibernate.proxy"); metadataSources.addAnnotatedClass(Company.class); metadataSources.addAnnotatedClass(Employee.class); Metadata metadata = metadataSources.buildMetadata(); return metadata.getSessionFactoryBuilder(); }
Example #10
Source File: HibernateUtil.java From tutorials with MIT License | 5 votes |
private static SessionFactoryBuilder getSessionFactoryBuilder(ServiceRegistry serviceRegistry) { MetadataSources metadataSources = new MetadataSources(serviceRegistry); metadataSources.addPackage("com.baeldung.hibernate.interceptors"); metadataSources.addAnnotatedClass(User.class); Metadata metadata = metadataSources.buildMetadata(); return metadata.getSessionFactoryBuilder(); }
Example #11
Source File: MetadataImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public SessionFactoryBuilder getSessionFactoryBuilder() { final SessionFactoryBuilderImpl defaultBuilder = new SessionFactoryBuilderImpl( this, bootstrapContext ); final ClassLoaderService cls = metadataBuildingOptions.getServiceRegistry().getService( ClassLoaderService.class ); final java.util.Collection<SessionFactoryBuilderFactory> discoveredBuilderFactories = cls.loadJavaServices( SessionFactoryBuilderFactory.class ); SessionFactoryBuilder builder = null; List<String> activeFactoryNames = null; for ( SessionFactoryBuilderFactory discoveredBuilderFactory : discoveredBuilderFactories ) { final SessionFactoryBuilder returnedBuilder = discoveredBuilderFactory.getSessionFactoryBuilder( this, defaultBuilder ); if ( returnedBuilder != null ) { if ( activeFactoryNames == null ) { activeFactoryNames = new ArrayList<>(); } activeFactoryNames.add( discoveredBuilderFactory.getClass().getName() ); builder = returnedBuilder; } } if ( activeFactoryNames != null && activeFactoryNames.size() > 1 ) { throw new HibernateException( "Multiple active SessionFactoryBuilderFactory definitions were discovered : " + String.join(", ", activeFactoryNames) ); } if ( builder != null ) { return builder; } return defaultBuilder; }
Example #12
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyJdbcFetchSize(int size) { this.optionsBuilder.applyJdbcFetchSize( size ); return this; }
Example #13
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyQuerySubstitutions(Map substitutions) { this.optionsBuilder.applyQuerySubstitutions( substitutions ); return this; }
Example #14
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled) { this.optionsBuilder.enableNamedQueryCheckingOnStartup( enabled ); return this; }
Example #15
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled) { this.optionsBuilder.enableSecondLevelCacheSupport( enabled ); return this; }
Example #16
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder enableJpaQueryCompliance(boolean enabled) { this.optionsBuilder.enableJpaQueryCompliance( enabled ); return this; }
Example #17
Source File: AbstractTest.java From high-performance-java-persistence with Apache License 2.0 | 4 votes |
private SessionFactory newSessionFactory() { final BootstrapServiceRegistryBuilder bsrb = new BootstrapServiceRegistryBuilder() .enableAutoClose(); Integrator integrator = integrator(); if (integrator != null) { bsrb.applyIntegrator( integrator ); } final BootstrapServiceRegistry bsr = bsrb.build(); final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder(bsr) .applySettings(properties()) .build(); final MetadataSources metadataSources = new MetadataSources(serviceRegistry); for (Class annotatedClass : entities()) { metadataSources.addAnnotatedClass(annotatedClass); } String[] packages = packages(); if (packages != null) { for (String annotatedPackage : packages) { metadataSources.addPackage(annotatedPackage); } } String[] resources = resources(); if (resources != null) { for (String resource : resources) { metadataSources.addResource(resource); } } final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder() .enableNewIdentifierGeneratorSupport(true) .applyImplicitNamingStrategy(ImplicitNamingStrategyLegacyJpaImpl.INSTANCE); final List<Type> additionalTypes = additionalTypes(); if (additionalTypes != null) { additionalTypes.stream().forEach(type -> { metadataBuilder.applyTypes((typeContributions, sr) -> { if(type instanceof BasicType) { typeContributions.contributeType((BasicType) type); } else if (type instanceof UserType ){ typeContributions.contributeType((UserType) type); } else if (type instanceof CompositeUserType) { typeContributions.contributeType((CompositeUserType) type); } }); }); } additionalMetadata(metadataBuilder); MetadataImplementor metadata = (MetadataImplementor) metadataBuilder.build(); final SessionFactoryBuilder sfb = metadata.getSessionFactoryBuilder(); Interceptor interceptor = interceptor(); if(interceptor != null) { sfb.applyInterceptor(interceptor); } return sfb.build(); }
Example #18
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { this.optionsBuilder.applyConnectionReleaseMode( connectionReleaseMode ); return this; }
Example #19
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 #20
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder enableJpaListCompliance(boolean enabled) { this.optionsBuilder.enableJpaListCompliance( enabled ); return this; }
Example #21
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver) { this.optionsBuilder.applyCurrentTenantIdentifierResolver( resolver ); return this; }
Example #22
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy) { this.optionsBuilder.applyMultiTenancyStrategy( strategy ); return this; }
Example #23
Source File: HibernateMetadata.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public SessionFactoryBuilder getSessionFactoryBuilder( MetadataImplementor metadataImplementor, SessionFactoryBuilderImplementor defaultBuilder ) { HibernateMetadata.metadataImplementor.set( metadataImplementor ); return defaultBuilder; }
Example #24
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyMaximumFetchDepth(int depth) { this.optionsBuilder.applyMaximumFetchDepth( depth ); return this; }
Example #25
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyDefaultBatchFetchSize(int size) { this.optionsBuilder.applyDefaultBatchFetchSize( size ); return this; }
Example #26
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyDelayedEntityLoaderCreations(boolean delay) { this.optionsBuilder.applyDelayedEntityLoaderCreations( delay ); return this; }
Example #27
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style) { this.optionsBuilder.applyBatchFetchStyle( style ); return this; }
Example #28
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling) { this.optionsBuilder.applyTempTableDdlTransactionHandling( handling ); return this; }
Example #29
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy) { this.optionsBuilder.applyMultiTableBulkIdStrategy( strategy ); return this; }
Example #30
Source File: SessionFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate) { this.optionsBuilder.applyEntityNotFoundDelegate( entityNotFoundDelegate ); return this; }