openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: Is it possible to override the default openjpa persistence provider
Date Tue, 30 Apr 2013 13:26:27 GMT
Is there a compelling reason that you're trying to extend OpenJPA? What
container are you running in? The reason I ask is that I see that org.apache
.openjpa.osgi.OSGiPersistenceProviderImpl is a valid provider. If you are
running in an OSGI environment, that will complicate things.


On Tue, Apr 30, 2013 at 1:00 AM, Subash Chaturanga <subashsdm@gmail.com>wrote:

> Any idea on this please ? Please find my question posted in SO [1] . This
> is regarding openjpa 2.2.0. And I think a custom provider class recognizes
> as unknown.
>
> Here is the code I found, this method evaluates to false for a custom
> provider class as for example public class MyProviderImpl implements
> PersistenceProvider, ProviderUtil
>
>
>     private static boolean
> *isOpenJPAPersistenceProvider*(PersistenceUnitInfo
> pinfo, ClassLoader loader) {
>         String provider = pinfo.getPersistenceProviderClassName();
>         if (StringUtils.isEmpty(provider) ||
> PersistenceProviderImpl.class.getName().equals(provider))
>             return true;
>
>         if (loader == null)
>             loader =
>
> AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
>         try {
>             if
> (PersistenceProviderImpl.class.isAssignableFrom(Class.forName(provider,
> false, loader)))
>                 return true;
>         } catch (Throwable t) {
>             log(_loc.get("unloadable-provider", provider, t).getMessage());
>             return false;
>         }
>         return false;
>     }
>
>
> [1]-
>
> http://stackoverflow.com/questions/16293136/openjpa-2-2-0-cannot-add-a-custom-persistence-provider-class-openjpa-recogniz
>
> On Mon, Apr 29, 2013 at 11:18 PM, Subash Chaturanga <subashsdm@gmail.com
> >wrote:
>
> > Hi
> > I wrote a MyProvider
> > extends org.apache.openjpa.persistence.PersistenceProviderImpl. And added
> > MyProvider as the provider in the persistence.xml.
> > Why I did this was to override the EntityManager.persist() method.  But
> > seems still the default provider class get picked up. Am i missing
> > something ?
> >
> > --
> > Subash Chaturanga
> > Sri Lanka
> >
> > Blog -  http://subashsdm.blogspot.com/
> > Twitter - http://twitter.com/subash89
> >
> >
>
>
>
> --
> Subash Chaturanga
> Department of Computer Science & Engineering
> University of Moratuwa
> Sri Lanka
>
> Blog -  http://subashsdm.blogspot.com/
> Twitter - http://twitter.com/subash89
>



-- 
*Rick Curtis*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message