[hibernate-dev] ORM5 : Reusing the Configuration instance

Steve Ebersole steve at hibernate.org
Wed Mar 18 13:10:06 EDT 2015


Probably we should re-initialize the service registries and builders held
within Configuration after the SF is built during
Configuration#buildSessionFactory.

Although, arguably what you are trying falls under the concept of sharing
service registries, and from that perspective is better handled through not
auto-closing them.

On Tue, Mar 17, 2015 at 9:48 AM, Hardy Ferentschik <hardy at hibernate.org>
wrote:

> Hi,
>
> On Mon, Mar 16, 2015 at 09:21:33PM +0000, Sanne Grinovero wrote:
> > > given that the SessionFactory gets closed after each test, I think it
> would
> > > only be fair to also rebuild the Configuration on each test set-up.
> > > What is the reason for keeping it around anyways? Do the tests run
> > > considerably slower when re-building the Configuration for each test?
> >
> > I'm not sure, git is pointing to your name :-) See:
> > org.hibernate.search.test.TestResourceManager
>
> Sure, I remember changing and refactoring the test base class quite often.
> However, the re-use of the Configuration is something which has been in
> the code
> as long as I remember.
>
> > It probably grew a bit of complexity over time and while I'm not sure
> > of what the original intention could be, I tend to agree with the
> > basic idea
>
> That the Configuration should be re-usable?
>
> > Even if we probably won't win much in terms of performance /
> > practicality and we were to agree to simplify this, the following
> > message is confusing:
> >
> > java.util.ServiceConfigurationError:
> > org.hibernate.service.spi.ServiceContributor: Provider
> > org.hibernate.search.hcore.impl.SearchFactoryServiceContributor not
> > found
> >      at java.util.ServiceLoader.fail(ServiceLoader.java:231)
> >      at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
> >      at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:365)
> >      at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
> >      at
> org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:339)
> >      at
> org.hibernate.boot.registry.StandardServiceRegistryBuilder.applyServiceContributors(StandardServiceRegistryBuilder.java:319)
> >      at
> org.hibernate.boot.registry.StandardServiceRegistryBuilder.build(StandardServiceRegistryBuilder.java:296)
> >      at
> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:740)
>
> +1
>
> --Hardy
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list