2 Replies Latest reply on Oct 21, 2002 2:38 AM by Alexey Loubyansky

    Tables created, but no relationships

    Ross Judson Newbie

      Using JBoss 3.0.3 and Hypersonic...seems like everything is doing what it should, but the relationship tables just don't get created. I am quite positive that I have made an error somewhere in my ejb-jar.xml but I just can't seem to see it. This is just a toy example that has a one to many relationship between a pooch and its leashes.

      Help!

      <?xml version="1.0"?>
      <!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>
      <display-name>Pooch</display-name>
      <enterprise-beans>

      <display-name></display-name>
      <ejb-name>PoochBean</ejb-name>
      pooch.PoochHome
      pooch.Pooch
      <local-home>pooch.PoochLocalHome</local-home>
      pooch.PoochLocal
      <ejb-class>pooch.PoochBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>pooch.PoochPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>PoochBean</abstract-schema-name>
      <cmp-field>
      <field-name>pooch_id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      </cmp-field>


      <display-name></display-name>
      <ejb-name>LeashBean</ejb-name>
      pooch.LeashHome
      pooch.Leash
      <local-home>pooch.LeashLocalHome</local-home>
      pooch.LeashLocal
      <ejb-class>pooch.LeashBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>pooch.LeashPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>LeashBean</abstract-schema-name>
      <cmp-field>
      <field-name>leash_id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      </cmp-field>

      </enterprise-beans>

      <ejb-relation>

      <ejb-relation-name>pooch-leashes</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>PoochBean to LeashBean</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>PoochBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>leashes</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>LeashBean to PoochBean</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>LeashBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>pooch</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>

      <assembly-descriptor>
      <container-transaction>

      <ejb-name>PoochBean</ejb-name>
      <method-name>*</method-name>


      <ejb-name>LeashBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>

        • 1. Re: Tables created, but no relationships
          Ross Judson Newbie

          Just a bit more info -- note that the tables are created but the relationship tables aren't.

          09:06:13,771 INFO [MainDeployer] Starting deployment of package: file:/D:/open/
          jboss-all/build/output/jboss-3.0.3/server/default/deploy/Pooch.jar
          09:06:13,981 INFO [EjbModule] Creating
          09:06:14,001 INFO [EjbModule] Deploying PoochBean
          09:06:14,222 INFO [EjbModule] Deploying LeashBean
          09:06:14,312 INFO [EjbModule] Created
          09:06:14,312 INFO [EjbModule] Starting
          09:06:16,034 INFO [LeashBean] Created table 'LEASHBEAN' successfully.
          09:06:16,094 INFO [PoochBean] Created table 'POOCHBEAN' successfully.
          09:06:16,094 INFO [EjbModule] Started
          09:06:16,104 INFO [MainDeployer] Deployed package: file:/D:/open/jboss-all/buil
          d/output/jboss-3.0.3/server/default/deploy/Pooch.jar

          • 2. Re: Tables created, but no relationships
            Alexey Loubyansky Master

            You have one-to-many relationship. So there is no a special table for relationship. There should be only foreign key column in the table that represents the many side.