Mark,

I did a lot of research on this and found that OpenJPA with Apache Aries is the 
best way to go.  Aries supports a few different JPA providers (not Hibernate 
for various technical reasons), OpenJPA seemed to be the best of them.

Then, by making the datasource it's own bundle, I set configuration in the 
feature so that just by changing the feature, the database is reconfigured 
between providers such as PostgreSQL or MySQL.  This allows specific users to 
select which database they want to use and have it configured properly just by 
selecting the proper feature to compliment OpenJPA with.  For instance:

> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"; 
> name="datasource">
>     
> <repository>mvn:org.apache.karaf.features/enterprise/3.0.0-SNAPSHOT/xml/features</repository>
>     <feature description="Datasource" version="1.0.0-SNAPSHOT" 
> name="datasource">
>         <feature>jndi</feature>
>         <feature>transaction</feature>
>         <bundle>wrap:mvn:com.experlog/xapool/1.5.0</bundle>
>         
> <bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
>         
> <bundle>mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.5_spec/2.0.0</bundle>
>         <bundle>wrap:mvn:aopalliance/aopalliance/1.0</bundle>
>         <bundle>wrap:mvn:commons-logging/commons-logging/1.1.1</bundle>
>     </feature>
> 
>     <feature description="PostgreSQL Data Source" version="3.0.0-SNAPSHOT" 
> name="PostgresDS">
>         <feature version="${pom.version}">datasource</feature>
>         <bundle>wrap:mvn:postgresql/postgresql/8.4-701.jdbc4</bundle>
>         <config name="datasource">
>             jdbc.driverClassName=org.postgresql.Driver
>             jdbc.url=jdbc:postgresql:metc
>             jdbc.username=metc
>             jdbc.password=pw4metc
>         </config>
>     </feature>
> </features>
> 

Hope that helps.  

Brian

On Aug 30, 2012, at 9:38 AM, Mark Ashworth <[email protected]> wrote:

> Good day,
> 
> I come from a JEE environment that is primarily dominated by EJB, JPA and
> JSF and I have found that many of these heavy weight approaches do not work
> so well. For example, I tried JSF but found that the Apache Wicket library
> together with Pax-Wicket was a far better approach. 
> 
> I am now trying to determine the best database access strategy to use so if
> there are any suggestions that would most appreciated.
> 
> Regards,
> Mark P Ashworth
> http://mpashworth.wordpress.com 
> 
> 
> 
> --
> View this message in context: 
> http://karaf.922171.n3.nabble.com/Best-database-access-strategy-to-use-in-OSGi-environment-tp4025883.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to