How to configure CMP data source?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to configure CMP data source?

tjsaker
This post was updated on .
I'm using OpenEJB 3.1.4.  How do I specify a data source for a CMP_ENTITY container?  The documentation specifies the following:

    <Container id="My MySQL Container" type="CMP_ENTITY">
        PoolSize = 100
        Global_TX_Database = conf/mysql.cmp.global-database.xml
        Local_TX_Database = conf/mysql.cmp.local-database.xml
    </Container>

Do I need to put the datasource settings in the indicated files?  I can find no further documentation on the format of mysql.cmp.global-database.xml or mysql.cmp.local-database.xml.
Reply | Threaded
Open this post in threaded view
|

Re: How to configure CMP data source

dblevins
Administrator

On Feb 7, 2011, at 12:18 PM, tjsaker wrote:

>
> I'm using OpenEJB 3.1.4.  How do I specify a data source for a CMP_ENTITY
> container?  The documentation specifies the following:
>
>    <Container id="My MySQL Container" type="CMP_ENTITY">
>        PoolSize = 100
>        Global_TX_Database = conf/mysql.cmp.global-database.xml
>        Local_TX_Database = conf/mysql.cmp.local-database.xml
>    </Container>
>
> Do I need to put the datasource settings in the indicated files?  I can find
> no further documentation on the format of mysql.cmp.global-database.xml or
> mysql.cmp.local-database.xml.

Oh geez, that's really old documentation.  Can you point out the page where you found it so we can update it?

Try this:

  - yank the <Container> declaration for CMP and let OpenEJB auto create a CMP container for you.
  - In the EJB jar where the cmp beans live, add a META-INF/persistence.xml file like the following.

  <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
      <persistence-unit transaction-type="JTA" name="cmp">
          <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
          <jta-data-source>My DataSource</jta-data-source>
          <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
          <properties>
              <!--<property name="openjpa.Log" value="DefaultLevel=TRACE"/>-->
              <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
          </properties>
      </persistence-unit>
  </persistence>

Internally we adapt CMP beans to JPA.  If you use the system property 'openejb.descriptors.output=true' we'll actually print out all the generated persistence and mapping files.  Then you can include them in your jar and tweak them if you want.

A couple important notes:
  - do not change the persistence-unit name.  it must be "cmp" for us to find it.
  - only openjpa is supported as the cmp persistence provider. the code is 95% generic but there are a couple hooks we needed that weren't covered in the plain JPA api.

It's been quite a long time since I or anyone worked on it, but there is some undocumented code in there that does allow some mixing of cmp/jpa with the idea being that one could slowly convert a CMP app to JPA.  I doubt anyone has the time/motivation to do any coding on it these days, but if that kind of feature is attractive to you I can certainly be as supportive as possible in answering questions, applying patches, and getting you what you need to really dig and make it work for you.

-David


 
Reply | Threaded
Open this post in threaded view
|

Re: How to configure CMP data source

tjsaker
Home page -> Configuration -> Containers (http://openejb.apache.org/containers.html)

So where do I find the current documentation?  Now I don't trust anything I've studied on the main site.
Reply | Threaded
Open this post in threaded view
|

Re: How to configure CMP data source

dblevins
Administrator

On Feb 7, 2011, at 8:02 PM, tjsaker wrote:

>
> Home page -> Configuration -> Containers (
> http://openejb.apache.org/containers.html
> http://openejb.apache.org/containers.html )
>
> So where do I find the current documentation?  Now I don't trust anything
> I've studied on the main site.

Thanks, I've cut that section off the left nav.  It had good info, but the CMP parts specifically were out of date.

The main source is this (the documentation link off the main page):

  http://openejb.apache.org/3.0/index.html


-David