Search in sources :

Example 1 with SessionFactoryServiceRegistry

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

the class ClearEventListenerTest 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).setListeners(EventType.CLEAR, listener);
        }

        @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 2 with SessionFactoryServiceRegistry

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

the class LegacyPostCommitListenerTest 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.POST_COMMIT_DELETE).appendListener(postCommitDeleteEventListener);
            serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_UPDATE).appendListener(postCommitUpdateEventListener);
            serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_INSERT).appendListener(postCommitInsertEventListener);
        }

        @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 3 with SessionFactoryServiceRegistry

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

the class PostCommitListenerTest 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.POST_COMMIT_DELETE).appendListener(postCommitDeleteEventListener);
            serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_UPDATE).appendListener(postCommitUpdateEventListener);
            serviceRegistry.getService(EventListenerRegistry.class).getEventListenerGroup(EventType.POST_COMMIT_INSERT).appendListener(postCommitInsertEventListener);
        }

        @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 4 with SessionFactoryServiceRegistry

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

the class TestAutoFlushBeforeQueryExecution 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 5 with SessionFactoryServiceRegistry

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

the class CallbackTest 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).setListeners(EventType.DELETE, listener);
            listener.initialize();
        }

        @Override
        public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
            listener.cleanup();
        }
    });
}
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)

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