persistence@glassfish.java.net

Re: [Issue 78] TopLink expects PU names to be unique across applications.

From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
Date: Thu, 08 Dec 2005 23:48:32 +0530

Hi Craig,

That combination would not work because PU names are not unit in an
application. They are only unique in the scope of the module in which
they are defined. The Java EE platform does not enforce a separate class
loader for each module. So the following is possible:

a.ear
     lib/par.jar // defined PU
     ejb.jar // defined PU1
     web.war // defines PU1

and there can be a single class loader shared by ejb.jar as well as web.war.

*I still don't understand what's the need of the map?*

I actually like the fact that PU names do not have to be unique in an
app because it's a nightmare to give unique names across modules while
developing complex test cases. Since a PU is private to a module, it
should not pollute the global namespace.

Thanks,
Sahoo

Craig L Russell wrote:

> Hi,
>
> The combination of class loader and PU should be unique. So you could
> have a static Map in the class loaded by the system class loader that
> was keyed from the class loader, and the class loader-specific
> structure has a Map of String to PU.
>
> In order to clean up the Map at undeployment, you need an application
> lifecycle callback or a weak Map.
>
> Craig
>
> On Dec 8, 2005, at 8:13 AM, Tom Ware wrote:
>
>> Sahoo,
>>
>> I just had a quick chat with Mike Keith. And he is hoping we can
>> come up with some ideas about how to uniquely identify the PU (since
>> the name is not unique as mentioned below). When we come up with a
>> good solution, it will be brought up as part of the spec discussions.
>>
>> Our initial suggestion is that the container provide some kind of
>> identifier to the persistence provider in the PersistenceUnitInfo.
>> This could possibly be a String pointing to the location of the
>> persistence unit, a URL, or some other String that uniquely
>> identifies the persistence unit when used in conjunction with the name.
>>
>> What do you think? Do you have any suggestions?
>>
>> Thanks,
>> Tom
>>
>> Tom Ware wrote:
>>
>>> The problem is that based on the information available, there is no
>>> way to uniquely identify the PU and since the spec says that if we
>>> call this method with the same PU, we have to redeploy, there is
>>> know way to know which path to take. I have been told the spec
>>> comittee is discussing this.
>>>
>>> -Tom
>>>
>>> Sanjeeb Kumar Sahoo wrote:
>>>
>>>
>>>
>>>> Hi Tom,
>>>> I don't know what is the confusion here. Any way, can't we at least
>>>> fix such that PU names does not have to be unique across the JVM?
>>>>
>>>> Thanks,
>>>> Sahoo
>>>> tware_at_dev.java.net <mailto:tware_at_dev.java.net> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>> https://glassfish.dev.java.net/issues/show_bug.cgi?id=78
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ------- Additional comments from tware_at_dev.java.net
>>>>> <mailto:tware_at_dev.java.net> Thu Dec 8 13:57:26 +0000 2005 -------
>>>>> The spec will be providing clarification about this issue. We
>>>>> will make changes when the new information is available.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>
> Craig Russell
>
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
>
> 408 276-5638 mailto:Craig.Russell_at_sun.com
>
> P.S. A good JDO? O, Gasp!
>
>