dev@glassfish.java.net

Re: Faulty persistence loading

From: Bill Shannon <bill.shannon_at_sun.com>
Date: Wed, 01 Feb 2006 19:55:51 -0800

The persistence spec provides a way to get a temp class loader.
My understanding is that it is intended to be used exactly as
you described, to discover the persistence classes before they're
loaded "for real".

> It seems to me we need to change the way persistence units are loaded in the application server to the following :
>
> - open the archive
> - create a temp class loader
> - find all persistence units and initialize the PersistenceProvider with each of them and get the ClassTransformer from the provider
> - initialize a new ClassLoader with the ClassTransformer to use from now on
> - process Java EE annotations
> - load XML
> - (deployment)
> - load applications.
>
> When there are no persistence units in the deployment artifact, we skip 2, 3 and 4

I assume after step 1 you scan the archive for annotations and determine
if there's a persistence unit based on whether there are any classes
with the @Entity annotation, or there's a persistence.xml file.