5 Replies Latest reply on Oct 1, 2002 3:54 PM by Tom Kale

    One to Many Collection empty

    F Zemen Newbie

      Context: JBoss 3.0.2 w/Tomcat over Oracle8

      I have a standard one to many relationship. From the one side, I can insert into the collection entities of the many side in ejbPostCreate, and in the same transaction, retrieve them.

      When I try to retrieve them afterward in another transaction the collection is empty. If I restart JBoss the colleciton is still empty.

      The database contains the data, and foreign keys are set and valid.

      Below are the fragments necessary for configuration of the many to one sides


      Product
      <ejb-name>ProductEJB</ejb-name>
      <local-home>com.parago.campaignsetup.persistence.ProductLocalHome</local-home>
      com.parago.campaignsetup.persistence.ProductLocal
      <ejb-class>com.parago.campaignsetup.persistence.ProductBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>product</abstract-schema-name>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>name</field-name></cmp-field>
      <cmp-field><field-name>description</field-name></cmp-field>
      <cmp-field><field-name>imageName</field-name></cmp-field>
      <cmp-field><field-name>statusId</field-name></cmp-field>
      <cmp-field><field-name>isTemplate</field-name></cmp-field>
      <cmp-field><field-name>manufacturerId</field-name></cmp-field>
      <cmp-field><field-name>webName</field-name></cmp-field>
      <cmp-field><field-name>createdDate</field-name></cmp-field>
      <cmp-field><field-name>updatedDate</field-name></cmp-field>
      <primkey-field>id</primkey-field>
      <env-entry>
      <env-entry-name>sequence/name</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>PRODUCT_SEQ</env-entry-value>
      </env-entry>
      <env-entry>
      <env-entry-name>sequence/dataSourceJNDI</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>java:CampaignDS</env-entry-value>
      </env-entry>

      Find By Name
      <query-method>
      <method-name>findByName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      SELECT DISTINCT OBJECT(o)
      FROM product o
      WHERE o.name=?1
      </ejb-ql>




      Product Attribute
      <ejb-name>ProductAttributeEJB</ejb-name>
      <local-home>com.parago.campaignsetup.persistence.ProductAttributeLocalHome</local-home>
      com.parago.campaignsetup.persistence.ProductAttributeLocal
      <ejb-class>com.parago.campaignsetup.persistence.ProductAttributeBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>productAttribute</abstract-schema-name>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>attributeMasterId</field-name></cmp-field>
      <cmp-field><field-name>typeId</field-name></cmp-field>
      <cmp-field><field-name>stringValue</field-name></cmp-field>
      <cmp-field><field-name>isMultivalued</field-name></cmp-field>
      <cmp-field><field-name>format</field-name></cmp-field>
      <cmp-field><field-name>createdDate</field-name></cmp-field>
      <cmp-field><field-name>updatedDate</field-name></cmp-field>
      <cmp-field><field-name>displayOrder</field-name></cmp-field>
      <primkey-field>id</primkey-field>
      <env-entry>
      <env-entry-name>sequence/name</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>PRODUCT_ATTRIB_SEQ</env-entry-value>
      </env-entry>
      <env-entry>
      <env-entry-name>sequence/dataSourceJNDI</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>java:CampaignDS</env-entry-value>
      </env-entry>



      <ejb-relation>

      <ejb-relation-name>Product-Has-Attributes</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Product Role</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>ProductEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>attributes</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Product Attribute Role</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>ProductAttributeEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>product</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>



      <ejb-name>ProductEJB</ejb-name>
      java:/CampaignDS
      <datasource-mapping>Oracle8</datasource-mapping>
      <table-name>Campaign.Product</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>Product_Id</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      <column-name>Name</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>description</field-name>
      <column-name>Descr</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>imageName</field-name>
      <column-name>Image_Name</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>manufacturerId</field-name>
      <column-name>Manufacturer_Id</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>webName</field-name>
      <column-name>Web_Name</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>statusId</field-name>
      <column-name>status_lookup_id</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>isTemplate</field-name>
      <column-name>Is_Template_Flag</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>createdDate</field-name>
      <column-name>Insert_Date</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>updatedDate</field-name>
      <column-name>Update_Date</column-name>
      </cmp-field>




      <ejb-name>ProductAttributeEJB</ejb-name>
      java:/CampaignDS
      <datasource-mapping>Oracle8</datasource-mapping>
      <table-name>Campaign.Product_Attrib</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>Product_Attrib_Id</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>attributeMasterId</field-name>
      <column-name>product_Attrib_Master_id</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>typeId</field-name>
      <column-name>type_lookup_id</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>stringValue</field-name>
      <column-name>Value</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>isMultivalued</field-name>
      <column-name>Is_Multivalued_Flag</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>displayOrder</field-name>
      <column-name>Display_Order</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>format</field-name>
      <column-name>Format</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>createdDate</field-name>
      <column-name>Insert_Date</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>updatedDate</field-name>
      <column-name>Update_Date</column-name>
      </cmp-field>



      <ejb-relation>
      <ejb-relation-name>Product-Has-Attributes</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Product Role</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <!-- This is the field name in Product that will be used as the foreign key in the batch -->
      <field-name>id</field-name>
      <!-- This is the name of the foreign key in the batch TABLE that JBoss will map to the field above in Lot -->
      <column-name>Product_Id</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Product Attribute Role</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>