Uploaded image for project: 'OpenEJB'
  1. OpenEJB
  2. OPENEJB-2097

EJB 2.1 CMB Entity Beans support on Tomme

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • cmp2
    • None

    Description

      We are migrating our EJB applications from weblogic 10.3.5 to Tomme 1.6. We followed the sample provided in the below link for migrating out EJB 2.1 CMP Entity Beans:
      http://tomee.apache.org/examples-trunk/simple-cmp2/README.html?_sm_au_=i2MFrT4NRW5HF6bs

      We are able to create CMP Entity Beans on Tomee using the sample available on the above link after making some modifications.
      The sample is intended for having CMP Entity Bean in the name of the table. For e.g. If my CMP Entity Bean name is MovieBean, then I need to have a table in the database only in the name MovieBean.
      When I try to point to a different table called Movie by having a mapping file (my-orm.xml) and configuration for that mapping file in the persistence.xml, I’m getting the following warning message:
      openjpa.MetaData - Found duplicate metadata or mapping for "class XXX.XXX1". Ignoring.

      The configuration are being picked from ejb-jar.xml, not from the mapping file.
      The content of persistence.xml and my-orm.xml are given below:

      Persistence.xml:

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
      <persistence-unit name="cmp" transaction-type="JTA">
      <jta-data-source>MyDataSource</jta-data-source>
      <non-jta-data-source>MyNonDataSource</non-jta-data-source>
      <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
      <mapping-file>META-INF/my-orm.xml</mapping-file>
      <class>com.tcm.cmp.MovieBean</class>
      <properties>
      <property name="openjpa.jdbc.SynchronizeMappings"
      value="buildSchema(ForeignKeys=true, Indexes=false, IgnoreErrors=true)"/>
      <!-- We have tried with the below validate value for mapping openjpa.jdbc.SynchronizeMappings -->
      <!--<property name="openjpa.jdbc.SynchronizeMappings"
      value="validate"/> -->
      <property name="openjpa.Log" value="DefaultLevel=INFO"/>
      </properties>

      </persistence-unit>
      </persistence>

      My-orm.xml

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0">
      <entity class="openejb.com.tcm.cmp.MovieBean" name="MovieBean">
      <description>MovieBean</description>
      <table name="Movie_Bean"/>
      <named-query name="MovieBean.findByDirector(java.lang.String)">
      <query>SELECT m FROM MovieBean m WHERE m.director = ?1</query>
      </named-query>
      <named-query name="MovieBean.findAll">
      <query>SELECT m FROM MovieBean as m</query>
      </named-query>
      <attributes>
      <id name="id">
      <column name="id"/>
      <generated-value strategy="IDENTITY"/>
      </id>

      <basic name="director" >
      <column name="director"/>
      </basic>

      <basic name="year">
      <column name="year"/>
      </basic>

      <basic name="title">
      <column name="title"/>
      </basic>
      </attributes>
      </entity>
      </entity-mappings>

      ejb-jar.xml:

      <ejb-jar>
      <enterprise-beans>
      <entity>
      <ejb-name>MovieBean</ejb-name>
      <home>com.tcm.cmp.Movies</home>
      <remote>com.tcm.cmp.Movie</remote>
      <ejb-class>com.tcm.cmp.MovieBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      <reentrant>false</reentrant>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>MovieBean</abstract-schema-name>
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>director</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>year</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>title</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>
      <query>
      <query-method>
      <method-name>findByDirector</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT m FROM MovieBean m WHERE m.director = ?1</ejb-ql>
      </query>
      <query>
      <query-method>
      <method-name>findAll</method-name>
      <method-params/>
      </query-method>
      <ejb-ql>SELECT m FROM MovieBean as m</ejb-ql>
      </query>
      </entity>
      </enterprise-beans>
      </ejb-jar>

      If I don’t give the <query> in ejb.jar.xml, I’m getting the error saying “No Query defined for MovieBean.findAll"

      Could be please share your findings on EJB 2.1 CMB Entity bean support for Tomee? Is it possible to provide custom table names for EJB 2.1 CMB Entity bean using mapping file?

      Attachments

        Activity

          People

            Unassigned Unassigned
            rajbabu Rajbabu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: