Search in sources :

Example 6 with SessionFactoryServiceRegistry

use of org.hibernate.service.spi.SessionFactoryServiceRegistry in project hibernate-orm by hibernate.

the class TestCollectionInitializingDuringFlush method prepareBootstrapRegistryBuilder.

@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
    super.prepareBootstrapRegistryBuilder(builder);
    builder.applyIntegrator(new Integrator() {

        @Override
        public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
            integrate(serviceRegistry);
        }

        private void integrate(SessionFactoryServiceRegistry serviceRegistry) {
            serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.PRE_UPDATE).appendListener(InitializingPreUpdateEventListener.INSTANCE);
        }

        @Override
        public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
        }
    });
}
Also used : SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Metadata(org.hibernate.boot.Metadata) Integrator(org.hibernate.integrator.spi.Integrator) SessionFactoryServiceRegistry(org.hibernate.service.spi.SessionFactoryServiceRegistry) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry)

Example 7 with SessionFactoryServiceRegistry

use of org.hibernate.service.spi.SessionFactoryServiceRegistry in project hibernate-orm by hibernate.

the class EagerKeyManyToOneTest method prepareBootstrapRegistryBuilder.

@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
    super.prepareBootstrapRegistryBuilder(builder);
    builder.applyIntegrator(new Integrator() {

        @Override
        public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
            integrate(serviceRegistry);
        }

        private void integrate(SessionFactoryServiceRegistry serviceRegistry) {
            serviceRegistry.getService(EventListenerRegistry.class).prependListeners(EventType.LOAD, new CustomLoadListener());
        }

        @Override
        public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
        }
    });
}
Also used : SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Metadata(org.hibernate.boot.Metadata) Integrator(org.hibernate.integrator.spi.Integrator) SessionFactoryServiceRegistry(org.hibernate.service.spi.SessionFactoryServiceRegistry)

Example 8 with SessionFactoryServiceRegistry

use of org.hibernate.service.spi.SessionFactoryServiceRegistry in project uPortal by Jasig.

the class DelayedValidationQueryResolverImpl method setConfiguration.

@Override
public void setConfiguration(String persistenceUnit, HibernateConfiguration hibernateConfiguration) {
    final SessionFactoryServiceRegistry serviceRegistry = hibernateConfiguration.getServiceRegistry();
    synchronized (this.delayedDataSources) {
        this.dialectResolver = serviceRegistry.getService(DialectResolver.class);
        for (final Tuple<DataSource, ValidationQueryRegistrationHandler> delayedDataSource : this.delayedDataSources) {
            final String validationQuery = this.getValidationQuery(delayedDataSource.first);
            delayedDataSource.second.setValidationQuery(validationQuery);
        }
        this.delayedDataSources.clear();
    }
}
Also used : DialectResolver(org.hibernate.service.jdbc.dialect.spi.DialectResolver) SessionFactoryServiceRegistry(org.hibernate.service.spi.SessionFactoryServiceRegistry) DataSource(javax.sql.DataSource)

Aggregations

SessionFactoryServiceRegistry (org.hibernate.service.spi.SessionFactoryServiceRegistry)8 Metadata (org.hibernate.boot.Metadata)7 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)7 Integrator (org.hibernate.integrator.spi.Integrator)7 EventListenerRegistry (org.hibernate.event.service.spi.EventListenerRegistry)4 DataSource (javax.sql.DataSource)1 DialectResolver (org.hibernate.service.jdbc.dialect.spi.DialectResolver)1