[hibernate-dev] ORM5 : Reusing the Configuration instance

Hardy Ferentschik hardy at hibernate.org
Mon Mar 16 16:57:19 EDT 2015


Hi,

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?

--Hardy

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.
> 
> Thanks,
> Sanne
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 496 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/hibernate-dev/attachments/20150316/68e5b999/attachment.bin 


More information about the hibernate-dev mailing list