2 Replies Latest reply on Oct 15, 2002 4:59 AM by Paul Nardone

    null from CMR field instead of Collection?

    Paul Nardone Newbie

      Hi,

      I have two EJBs in a many to many realtion ship, one of them is returning null instead of a collection object. I've seen a similar post on here which said it was due to missing key fields but I think mine has them

      getUsers() on the Group is ok but getGroups() on the user returns null

      GroupEJB
      /** THe group side
      * @ejb:interface-method
      * view-type="local"
      * @ejb:relation
      * name="group-user"
      * role-name="many-group-has-many-user"
      * @jboss.relation
      * fk-column="USR_ID"
      * related-pk-field="uniqueKey"
      * @jboss.relation-table
      * table-name="DM_USER_GROUPS"
      * create-table="true"
      */
      public abstract java.util.Collection getUsers();

      /** Sets the users to be a member of this group
      * @param theUsers The users who will be set as a member of this group
      *
      *
      * @ejb:interface-method
      * view-type="local"
      */
      public abstract void setUsers(java.util.Collection theUsers);

      UserEJB
      /** The user side
      * @return The group id
      *
      *
      * @ejb:persistent-field
      * @ejb:interface-method
      * view-type="local"
      * @ejb:relation
      * name="group-user"
      * role-name="many-user-has-many-group"
      * @jboss.relation
      * fk-column="GRP_ID"
      * related-pk-field="uniqueKey"
      */
      public abstract java.util.Collection getGroups();

      /** Sets the group the user belongs to
      *
      *
      * @ejb:interface-method
      * view-type="local"
      */

      public abstract void setGroups(java.util.Collection theGroups);


      ejb-jar


      <ejb-relation >
      <ejb-relation-name>group-user</ejb-relation-name>

      <ejb-relationship-role >
      <ejb-relationship-role-name>many-group-has-many-user</ejb-relationship-role-name>
      Many
      <relationship-role-source >
      <ejb-name>Group</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>users</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role >
      <ejb-relationship-role-name>many-user-has-many-group</ejb-relationship-role-name>
      Many
      <relationship-role-source >
      <ejb-name>User</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>groups</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>

      </ejb-relation>



      jbosscmp-jdbc

      <ejb-relation>
      <ejb-relation-name>group-user</ejb-relation-name>
      <relation-table-mapping>
      <table-name>DM_USER_GROUPS</table-name>
      <create-table>true</create-table>
      </relation-table-mapping>

      <ejb-relationship-role>
      <ejb-relationship-role-name>many-group-has-many-user</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>uniqueKey</field-name>
      <column-name>GRP_ID</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>many-user-has-many-group</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>uniqueKey</field-name>
      <column-name>USR_ID</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>


      At first I thought it may be a database issue but it happens both on firebird and oracle.


      Any help much appreciated.

      Paul Nardone