users@jpa-spec.java.net

[jpa-spec users] [jsr338-experts] Re: Re: Picking the right persistence unit from multiple choices when no unitName is specified

From: Scott Marlow <smarlow_at_redhat.com>
Date: Wed, 19 Jun 2013 11:54:35 -0400

On 06/19/2013 11:07 AM, Matthew Adams wrote:
> Perhaps a Java system property called "javax.persistence.default-unit"
> would work here instead, since you're talking about a concept that spans
> multiple persistence units?

If all containers supported a global default-unit name, that would also
help application portability (doesn't matter where the global setting is
stored).

Or we could all agree that the container should fail the deployment for
the below (ambiguous) case.

>
>
> On Wed, Jun 19, 2013 at 6:50 AM, Scott Marlow <smarlow_at_redhat.com
> <mailto:smarlow_at_redhat.com>> wrote:
>
> Should application deployment fail if there are multiple persistence
> units defined and no unitName is specified? If not, which
> persistence unit should be picked?
>
> For example, given the below persistence.xml contents:
>
> "
> <persistence
> <persistence-unit name="rightpu1">
> </persistence-unit>
> <persistence-unit name="otherrightpu2">
> </persistence-unit>
> </persistence>
> "
>
> And a persistence context:
>
> "
> @PersistenceContext EntityManager randompu;
> "
>
> Should "rightpu1" be used or "otherrightpu2"?
>
> Should we have a standard pu property ("javax.persistence.default")
> that allows the default pu to be specified for this case?
>
> If the default pu property is not specified, should application
> deployment fail for this case? Or should the application deployment
> continue with whichever persistence unit the deployer happens to pick?
>
> Scott
>
>
>
>
> --
> mailto:matthew_at_matthewadams.me
> skype:matthewadams12
> googletalk:matthew_at_matthewadams.me
> <mailto:googletalk%3Amatthew_at_matthewadams.me>
> http://matthewadams.me
> http://www.linkedin.com/in/matthewadams