1 Reply Latest reply on Apr 23, 2002 3:24 PM by Antonio Kantek

    Binding between 2 beans without enrollment bean

    Antonio Kantek Newbie

      How I can describe this relationship in the jbosscmp-jdbc.xml ?
      I don't a enrollment bean to make the binding between the 2 entities.
      Please Help me!

      <ejb-relation>
      <ejb-relation-name>Material-ComplementoMaterial</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Entity1-BelongsTo-Entity2</ejb-relationship-role-name>
      many
      <relationship-role-source>
      <ejb-name>Entity1</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>entities2</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Enttiy2-BelongsTo-Entity1</ejb-relationship-role-name>
      many
      <relationship-role-source>
      <ejb-name>Entity2</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>entities1</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>

        • 1. Re: Binding between 2 beans without enrollment bean
          Antonio Kantek Newbie

          Take it easy my friend...
          This is your answer and pay attention in the dtd

          <?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:/DataSource
          <datasource-mapping>mySQL</datasource-mapping>
          <create-table>false</create-table>
          <remove-table>false</remove-table>
          <read-only>false</read-only>
          <time-out>30000</time-out>
          <row-locking>false</row-locking>
          <pk-constraint/>
          <fk-constraint/>
          <preferred-relation-mapping>relation-table</preferred-relation-mapping>
          <read-ahead>
          on-load
          <page-size>255</page-size>
          <eager-load-group>*</eager-load-group>
          </read-ahead>
          <list-cache-max>255</list-cache-max>


          <enterprise-beans>

          <ejb-name>Person</ejb-name>
          <table-name>JBOSS_TEST.PERSON</table-name>
          <cmp-field>
          <field-name>pk</field-name>
          <column-name>PK</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>name</field-name>
          <column-name>NAME</column-name>
          <jdbc-type>VARCHAR</jdbc-type>
          <sql-type>VARCHAR(30)</sql-type>
          </cmp-field>
          <cmp-field>
          <field-name>age</field-name>
          <column-name>AGE</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>categoryName</field-name>
          <column-name>CATEGORY_NAME</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>userName</field-name>
          <column-name>USERNAME</column-name>
          </cmp-field>



          <ejb-name>Company</ejb-name>
          <table-name>JBOSS_TEST.COMPANY</table-name>
          <cmp-field>
          <field-name>pk</field-name>
          <column-name>PK</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>name</field-name>
          <column-name>NAME</column-name>
          <jdbc-type>VARCHAR</jdbc-type>
          <sql-type>VARCHAR(30)</sql-type>
          </cmp-field>
          <cmp-field>
          <field-name>categoryName</field-name>
          <column-name>CATEGORY_NAME</column-name>
          </cmp-field>



          <ejb-name>Category</ejb-name>
          <table-name>JBOSS_TEST.CATEGORY</table-name>
          <cmp-field>
          <field-name>name</field-name>
          <column-name>NAME</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>parentName</field-name>
          <column-name>PARENT</column-name>
          </cmp-field>



          <ejb-name>Descriptor</ejb-name>
          <table-name>JBOSS_TEST.DESCRIPTOR</table-name>
          <cmp-field>
          <field-name>name</field-name>
          <column-name>NAME</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>pk</field-name>
          <column-name>PK</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>type</field-name>
          <column-name>TYPE</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>categoryName</field-name>
          <column-name>CATEGORYNAME</column-name>
          </cmp-field>



          <ejb-name>Attribute</ejb-name>
          <table-name>JBOSS_TEST.ATTRIBUTE</table-name>
          <cmp-field>
          <field-name>pk</field-name>
          <column-name>PK</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>descriptorPk</field-name>
          <column-name>DESCRIPTOR_PK</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>value</field-name>
          <column-name>VALUE</column-name>
          </cmp-field>



          <ejb-name>Product</ejb-name>
          <table-name>JBOSS_TEST.PRODUCT</table-name>
          <cmp-field>
          <field-name>name</field-name>
          <column-name>NAME</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>price</field-name>
          <column-name>PRICE</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>pk</field-name>
          <column-name>PK</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>categoryName</field-name>
          <column-name>CATEGORY_NAME</column-name>
          </cmp-field>



          <ejb-name>CustomerOrder</ejb-name>
          <table-name>JBOSS_TEST.CUSTOMERORDER</table-name>
          <cmp-field>
          <field-name>pk</field-name>
          <column-name>PK</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>personPk</field-name>
          <column-name>PERSONPK</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>price</field-name>
          <column-name>PRICE</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>registrationDate</field-name>
          <column-name>REGISTRATION_DATE</column-name>
          </cmp-field>
          <cmp-field>
          <field-name>status</field-name>
          <column-name>STATUS</column-name>
          </cmp-field>

          </enterprise-beans>


          <ejb-relation>
          <ejb-relation-name>company-persons</ejb-relation-name>
          <foreign-key-mapping>
          </foreign-key-mapping>

          <ejb-relationship-role>
          <ejb-relationship-role-name>company-has-persons</ejb-relationship-role-name>
          <key-fields>
          <key-field>
          <field-name>pk</field-name>
          <column-name>COMPANY_PK</column-name>
          <jdbc-type>BIGINT</jdbc-type>
          <sql-type>BIGINT</sql-type>
          </key-field>
          </key-fields>

          </ejb-relationship-role>

          <ejb-relationship-role>
          <ejb-relationship-role-name>persons-belongsto-company</ejb-relationship-role-name>
          <key-fields/>
          </ejb-relationship-role>
          </ejb-relation>

          <ejb-relation>
          <ejb-relation-name>category-descriptors</ejb-relation-name>
          <foreign-key-mapping>
          </foreign-key-mapping>

          <ejb-relationship-role>
          <ejb-relationship-role-name>category-has-descriptors</ejb-relationship-role-name>
          <key-fields>
          <key-field>
          <field-name>name</field-name>
          <column-name>CATEGORYNAME</column-name>
          <jdbc-type>VARCHAR</jdbc-type>
          <sql-type>VARCHAR</sql-type>
          </key-field>
          </key-fields>
          </ejb-relationship-role>

          <ejb-relationship-role>
          <ejb-relationship-role-name>descriptors-belongsto-category</ejb-relationship-role-name>
          <key-fields/>
          </ejb-relationship-role>
          </ejb-relation>

          <ejb-relation>
          <ejb-relation-name>Product-Attributes</ejb-relation-name>
          <foreign-key-mapping>
          </foreign-key-mapping>

          <ejb-relationship-role>
          <ejb-relationship-role-name>Product-has-Attributes</ejb-relationship-role-name>
          <key-fields>
          <key-field>
          <field-name>pk</field-name>
          <column-name>PRODUCT_PK</column-name>
          <jdbc-type>BIGINT</jdbc-type>
          <sql-type>BIGINT</sql-type>
          </key-field>
          </key-fields>
          </ejb-relationship-role>

          <ejb-relationship-role>
          <ejb-relationship-role-name>Attributes-belongsto-Product</ejb-relationship-role-name>
          <key-fields/>
          </ejb-relationship-role>

          </ejb-relation>

          <ejb-relation>
          <ejb-relation-name>Products-CustomerOrders</ejb-relation-name>
          <relation-table-mapping>
          <table-name>PRODUCT_ORDER_BINDING</table-name>
          </relation-table-mapping>


          <ejb-relationship-role>
          <ejb-relationship-role-name>Product-has-CustomerOrders</ejb-relationship-role-name>
          <fk-constraint>CUSTOMERORDER_PK</fk-constraint>
          </ejb-relationship-role>

          <ejb-relationship-role>
          <ejb-relationship-role-name>CustomerOrders-belongsto-Product</ejb-relationship-role-name>
          <fk-constraint>PRODUCT_PK</fk-constraint>
          </ejb-relationship-role>
          </ejb-relation>




          </jbosscmp-jdbc>