1 Reply Latest reply on Oct 8, 2002 1:17 AM by kk

    Problem on creating config cmr in deployment descriptor?

    kk Newbie

      i try to make 2 entity bean with one to many relationship. When i create the "SampleDtl" , it problem invalid column name. any problem with my config. my config is
      ejb-jar.xml
      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE ejb-jar PUBLIC
      "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
      "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar>
      <enterprise-beans>

      <display-name>Sample Header Entity Bean</display-name>
      <ejb-name>SampleHdr</ejb-name>

      <local-home>com.gdb.app.sample.ejb.SampleHdrLocalHome</local-home>
      com.gdb.app.sample.ejb.SampleHdrLocal

      com.gdb.app.sample.ejb.SampleHdrHome
      com.gdb.app.sample.ejb.SampleHdrRemote
      <ejb-class>com.gdb.app.sample.ejb.SampleHdrBean</ejb-class>

      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>sample_hdr</abstract-schema-name>

      <cmp-field><field-name>hdrCode</field-name></cmp-field>
      <cmp-field><field-name>hdrDesc</field-name></cmp-field>

      <primkey-field>hdrCode</primkey-field>
      <security-identity><use-caller-identity/></security-identity>



      <display-name>Sample Detail Entity Bean</display-name>
      <ejb-name>SampleDtl</ejb-name>

      <local-home>com.gdb.app.sample.ejb.SampleDtlLocalHome</local-home>
      com.gdb.app.sample.ejb.SampleDtlLocal
      <ejb-class>com.gdb.app.sample.ejb.SampleDtlBean</ejb-class>

      <persistence-type>Container</persistence-type>
      <prim-key-class>com.gdb.app.sample.ejb.SampleDtlPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>sample_dtl</abstract-schema-name>

      <cmp-field><field-name>dtlHdrCode</field-name></cmp-field>
      <cmp-field><field-name>dtlCode</field-name></cmp-field>
      <cmp-field><field-name>dtlDesc</field-name></cmp-field>

      <!-- <primkey-field>gangsterId</primkey-field> -->



      <ejb-relation>
      <ejb-relation-name>SampleHdr-SampleDtl</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>samplehdr-has-sampledtls</ejb-relationship-role-name>

      One

      <relationship-role-source>
      <ejb-name>SampleHdr</ejb-name>
      </relationship-role-source>

      <cmr-field>
      <cmr-field-name>sampleDtls</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>sampledtl-belongs-to-samplehdr</ejb-relationship-role-name>

      Many

      <relationship-role-source>
      <ejb-name>SampleDtl</ejb-name>
      </relationship-role-source>

      <cmr-field>
      <cmr-field-name>sampleHdrLocal</cmr-field-name>
      </cmr-field>

      </ejb-relationship-role>
      </ejb-relation>


      </ejb-jar>

      =============================================
      jbosscmp-jdbc.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE jbosscmp-jdbc PUBLIC
      "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN"
      "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">

      <jbosscmp-jdbc>

      java:/OracleDS
      <datasource-mapping>Oracle9i</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <pk-constraint>true</pk-constraint>



      <enterprise-beans>


      <ejb-name>SampleHdr</ejb-name>
      <table-name>sample_hdr</table-name>

      <cmp-field>
      <field-name>hdrCode</field-name>
      <column-name>hdr_code</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>hdrDesc</field-name>
      <column-name>hdr_desc</column-name>
      </cmp-field>



      <ejb-name>SampleDtl</ejb-name>
      <table-name>sample_dtl</table-name>

      <cmp-field>
      <field-name>dtlHdrCode</field-name>
      <column-name>dtl_hdr_code</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>dtlCode</field-name>
      <column-name>dtl_code</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>dtlDesc</field-name>
      <column-name>dtl_desc</column-name>
      </cmp-field>




      <ejb-name>CustomerEJB</ejb-name>
      <table-name>customer</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>id</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      <column-name>last_name</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>first_name</column-name>
      </cmp-field>


      </enterprise-beans>



      <ejb-relation>
      <ejb-relation-name>SampleHdr-SampleDtl</ejb-relation-name>
      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>samplehdr-has-sampledtls</ejb-relationship-role-name>

      <key-fields>
      <key-field>
      <field-name>hdrCode</field-name>
      <column-name>hdr_Code</column-name>
      </key-field>
      </key-fields>


      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>sampledtl-belongs-to-samplehdr</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>



      </jbosscmp-jdbc>

        • 1. tables of entity beans
          kk Newbie

          SQL> desc sample_hdr
          Name Null? Type
          ----------------------------------------- -------- ---------------
          HDR_CODE NOT NULL VARCHAR2(255)
          HDR_DESC VARCHAR2(255)



          SQL> desc sample_dtl
          Name Null? Type
          ----------------------------------------- -------- -------------
          DTL_HDR_CODE NOT NULL VARCHAR2(10)
          DTL_CODE NOT NULL VARCHAR2(10)
          DTL_DESC VARCHAR2(10)
          DTL_NUM NUMBER(10)