override the persistence unit provider property

View: New views
3 Messages — Rating Filter:   Alert me  

override the persistence unit provider property

by hypnosat7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

  I've add a provider property in my jndi.properties file to avoid using openjpa provider:
# override properties of the "educaPU" persistence unit
educaPU.provider = org.eclipse.persistence.jpa.PersistenceProvider
educaPU.jta-data-source = educaDatabase
educaPU.non-jta-data-source = educaDatabase
educaPU.eclipselink.target-database = org.eclipse.persistence.platform.database.HSQLPlatform
educaPU.eclipselink.ddl-generation = drop-and-create-tables
educaPU.eclipselink.ddl-generation.output-mode = both


But I still see OpenJPA as a provider:
INFO - PersistenceUnit(name=educaPU, provider=org.apache.openjpa.persistence.PersistenceProviderImpl)


So how can I do to enforce the use of eclipselink ?
Thanks

Re: override the persistence unit provider property

by David Blevins :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 22, 2009, at 1:52 PM, hypnosat7 wrote:

>
> Hello,
>
>  I've add a provider property in my jndi.properties file to avoid  
> using
> openjpa provider:
> # override properties of the "educaPU" persistence unit
> educaPU.provider = org.eclipse.persistence.jpa.PersistenceProvider
> educaPU.jta-data-source = educaDatabase
> educaPU.non-jta-data-source = educaDatabase
> educaPU.eclipselink.target-database =
> org.eclipse.persistence.platform.database.HSQLPlatform
> educaPU.eclipselink.ddl-generation = drop-and-create-tables
> educaPU.eclipselink.ddl-generation.output-mode = both
>
>
> But I still see OpenJPA as a provider:
> INFO - PersistenceUnit(name=educaPU,
> provider=org.apache.openjpa.persistence.PersistenceProviderImpl)

The overrides go directly to the <persistence-unit>/<properties>  
element.

There are standard system properties for setting provider,  
datasources, and transaction type if you do not wish to specify them  
in the persistence.xml.

  - javax.persistence.provider
  - javax.persistence.transactionType
  - javax.persistence.jtaDataSource
  - javax.persistence.nonJtaDataSource


I wouldn't worry about setting the datasource names.  In most cases we  
can figure that out automatically.

-David


Re: override the persistence unit provider property

by hypnosat7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I'm using an embedded openejb, can I set the "javax.persistence.provider" property in a file ? in the jndi.properties it doesn't work.
Thanks.

David Blevins wrote:
On Oct 22, 2009, at 1:52 PM, hypnosat7 wrote:

>
> Hello,
>
>  I've add a provider property in my jndi.properties file to avoid  
> using
> openjpa provider:
> # override properties of the "educaPU" persistence unit
> educaPU.provider = org.eclipse.persistence.jpa.PersistenceProvider
> educaPU.jta-data-source = educaDatabase
> educaPU.non-jta-data-source = educaDatabase
> educaPU.eclipselink.target-database =
> org.eclipse.persistence.platform.database.HSQLPlatform
> educaPU.eclipselink.ddl-generation = drop-and-create-tables
> educaPU.eclipselink.ddl-generation.output-mode = both
>
>
> But I still see OpenJPA as a provider:
> INFO - PersistenceUnit(name=educaPU,
> provider=org.apache.openjpa.persistence.PersistenceProviderImpl)

The overrides go directly to the <persistence-unit>/<properties>  
element.

There are standard system properties for setting provider,  
datasources, and transaction type if you do not wish to specify them  
in the persistence.xml.

  - javax.persistence.provider
  - javax.persistence.transactionType
  - javax.persistence.jtaDataSource
  - javax.persistence.nonJtaDataSource


I wouldn't worry about setting the datasource names.  In most cases we  
can figure that out automatically.

-David