tags:

views:

243

answers:

1

Does anyone know how to create your own JPA provider? I was considering making a custom JPA provider that could interface with a SOAP webservice we use. However, I can't seem to find any document describing how to create your own JPA provider. Where should I start looking?

+1  A: 

You start by implementing javax.persistence.spi.PersistenceProvider interface and specifying your implementation using provider element within persistence unit declaration:

<persistence-unit name="myUnit">
  <provider>com.mypackage.CustomPersistenceProvider</provider>
  ...
</persistence-unit>

That gives you an entry point for creating your own EntityManagerFactory and, consequently, EntityManager.

The $64,000 question here, though, is why you would want to do something like this? If this is related to your Lazy Hibernate JPA using SOAP question then this is probably not the right approach to take.

ChssPly76
That's the answer I was looking for. It is definitely related to the other question. Do you think inflation levels are the best approach then? Shall I open another topic for that?
User1
Inflation levels approach is somewhat easier IF you can rely on client to supply appropriate ones; but proxy-based approach should work fine too. Is that what you're trying to do here? You don't need custom JPA to use proxies unless your client is using JPA directly (in which case I'm not sure how the whole SOAP proxy thing comes into play). Instead, when client asks your service for an entity you return a proxy which, when needed, calls same (or different) service to retrieve missing data.
ChssPly76