users@jpa-spec.java.net

[jpa-spec users] [jsr338-experts] 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 07:50:07 -0400

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