[hibernate-dev] ORM5 : Reusing the Configuration instance
sanne at hibernate.org
Mon Mar 16 17:21:33 EDT 2015
On 16 March 2015 at 20:57, Hardy Ferentschik <hardy at hibernate.org> 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:
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
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:
As an Hibernate ORM user I would expect the Configuration to be
reusable, and probably immutable as well.
> On Sun, Mar 15, 2015 at 11:36:00PM +0000, Sanne Grinovero wrote:
>> Hi all,
>> I'm trying to get an experimental branch of Hibernate Search to work
>> with the latest snapshot of Hibernate ORM 5.
>> After a bit of refactoring of our integration SPIs I thought it was
>> ready for some testing, but came to some surprising errors from the
>> ServiceLoader not finding the implementations from Hibernate Search -
>> although it would find the service definition of it.
>> After a bit more investigating, it turns out that the Integrator works
>> fine for each first test of our testsuite; it turns out that the
>> ClassLoaderService is referenced by the Configuration instance, and
>> this specific service nulls out all references to classloaders on
>> shutdown of the SessionFactory (which happens at the end of each of
>> our tests).
>> When the second test runs, it's reusing the same instance of ORM's
>> Configuration and so the ClassLoaderService gets reused and not
>> properly re-initialized, so it's not able to load any class.
>> So I'm wondering now if we should stop re-using the Configuration
>> instance in Search across tests, or if the ClassLoaderService in ORM
>> should be re-initialized on restart?
>> (this re-using business is mostly a convenience for how the Search
>> testsuite works but not strictly necessary)
>> If we should stop reusing the Configuration instances, then I'd like
>> to add a validation in ORM as the errormessage thrown from the
>> java.util.ServiceConfigurationError is confusing.
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
More information about the hibernate-dev