persistence@glassfish.java.net

Re: [Fwd: [Issue 1074] Regression: TopLink does not serach classpath for mapping files specified in persistence.xml]

From: Wonseok Kim <guruwons_at_gmail.com>
Date: Mon, 11 Sep 2006 15:05:04 +0900

Hi, Marina

I agree that orm.xml or mapping files in the PU root should be used if there
are multiple same name files in the classpath.
But if there is no one in PU root and we pick one of the same name mapping
files in the classpath, it can be unpredictable.
How about throwing an exception in that case? Of course if there is one
mapping file in the classpath, it should work.
If you agree with this, the 4th step should call getResources() and check
the number of returned resources.

I'm now curious that current impl can process several META-INF/orm.xml files
which exist in referenced jar files from persistence.xml. You mentioned it
is accomplished by current impl, but I couldn't find it in the code...
please instruct me.

Thanks
- Wonseok

On 9/9/06, Marina Vatkina <Marina.Vatkina_at_sun.com> wrote:
>
> Team,
>
> Do you have any idea of a simpler/better/nicer solution for locating
> mapping
> files in a PU?
>
> thanks,
> -marina
>
> -------- Original Message --------
> From: mvatkina_at_dev.java.net
> Subject: [Issue 1074] Regression: TopLink does not serach classpath for
> mapping
> files specified in persistence.xml
>
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=1074
>
>
>
> User mvatkina changed the following:
>
> What |Old value |New value
>
> ================================================================================
> Status|NEW |STARTED
>
> --------------------------------------------------------------------------------
>
>
>
>
> ------- Additional comments from mvatkina_at_dev.java.net Fri Sep 8 20:41:35
> +0000
> 2006 -------
> Here is what I learned about the current implementation:
>
> 1. Because there can be more than 1 persistence.xml on the classpath,
> META-INF/orm.xml or any other mapping file referenced from a
> persistence.xml,
> must be 1st looked up in the PU root or in any jar file referenced from
> that
> persistence.xml. Otherwise we can get some other PU's mapping files that
> are
> accidentally on the classpath (is it a spec oversight that there is no PU
> name
> in the mapping file?).
> This is accomplished by steps 1 and 2 in
> PersistenceUnitProcessor.createInputStreamForFileInPersistenceUnit().
>
> 2. In Tomcat the PU root is returned by a complicated URL that is handled
> by
> step 3 in the above method.
>
> The solution would be to add getResourceAsStream call as the 4th step, but
> it's
> not clear if we should attempt to do so for the default mapping file
> (META-INF/orm.xml).
>