openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Woods <>
Subject JPA2 - When should createEMF() return an Exception vs. NULL?
Date Thu, 23 Jul 2009 20:29:13 GMT
As part of implementing the PersistenceProviderResolver in 9.3 and 
hooking it into the createEMF() bootstraping in 9.2, another grey area 
has surfaced.

At the end of Section 9.2 -
"If a provider does not qualify as the provider for the named 
persistence unit, it must return null when createEntityManagerFactory is 
invoked on it. "

Our testcase - org.apache.openjpa.conf.TestSpecificationConfiguration
that sets the property openjpa.Specification="JPA 3.0" on createEMF() 
falls under bullet 3 right above that sentence -
"A provider may deem itself as appropriate for the persistence unit if 
any of the following are true:  No provider was specified for the 
persistence unit in either the persistence.xml or the property map."

Since no Provider was specified as a property, we (or any other 
provider) can choose to handle the createEMF() request.
Now, since an openjpa.* property was passed in, should we return an 
openjpa.ArgumentException (current behavior) or NULL on the createEMF() 
since we know we cannot handle the request?
For some other JPA provider, they would ignore the openjpa.Specification 
and possibly still fail or maybe they have implemented JPA 3.0 and would 
return a valid EMF.

So, the question is, do we make a major runtime change and return NULL, 
so another provider can try creating an EMF, or keep returning an 
exception and have the geronimo-jpa_2.0_spec rethrow it as a 
PersistenceException (which was the 1.0 behavior)?


View raw message