Discussions

EJB programming & troubleshooting: CMR and weblogic

  1. CMR and weblogic (2 messages)

    We have 2 tables EMPLOYEE and TIME_ENTRIES with the latter storing multiple timesheet entries for each employee entry.
    The relation is defined in ejb-jar as follows:
    <ejb-relation>

               <ejb-relation-name>Emp-Timesheets</ejb-relation-name>
               <ejb-relationship-role>
            <ejb-relationship-role-name>Emp-has-TSs</ejb-relationship-role-name>
            <multiplicity>One</multiplicity>
            <relationship-role-source>
              <ejb-name>Employee</ejb-name>
            </relationship-role-source>
            <cmr-field>
              <cmr-field-name>timeSheets</cmr-field-name>
              <cmr-field-type>java.util.Collection</cmr-field-type>
            </cmr-field>
              </ejb-relationship-role>

               <ejb-relationship-role>
            <ejb-relationship-role-name>TS-has-Emp</ejb-relationship-role-name>
            <multiplicity>Many</multiplicity>
            <relationship-role-source>
              <ejb-name>TimeSheet</ejb-name>
            </relationship-role-source>
            </ejb-relationship-role>

             </ejb-relation>
    The weblogic-cmp-rdbms-jar file has the following entry:

    <weblogic-rdbms-relation>

         <relation-name>Emp-Timesheets</relation-name>
         <weblogic-relationship-role>
         <relationship-role-name>Emp-has-TSs</relationship-role-name>
         </weblogic-relationship-role>
         <weblogic-relationship-role>
         <relationship-role-name>TS-has-Emp</relationship-role-name>
         <relationship-role-map>
         <column-map>
              <foreign-key-column>EMP_ID</foreign-key-column>
              <key-column>EMP_ID</key-column>
         </column-map>
         </relationship-role-map>
         </weblogic-relationship-role>

         </weblogic-rdbms-relation>
    Now we do a simple iteration on the returned collection as follows:
    public Collection getAllTimeSheets()
    {
    Collection tscoll = getTimeSheets();
    Iterator i = tscoll.iterator();
    while(i.hasNext())
    {
    TimeSheet t=(TimeSheet)i.next();
    p.println("data $$" + t.getHours());


    }
    Collection tsCopy = new ArrayList(tscoll);
    return tsCopy;
    }

    The getTimeSheets returns the correct number of records , but they are all repetitions of the first record.What is wrong?

    Threaded Messages (2)

  2. CMR and weblogic[ Go to top ]

    Hi,
       can you please paste the SQl here and use set in place of collection so that the duplicate records will not come. Well changing it to set won;t solve the problem but the SQl query can put more light on it .


    sawan
  3. CMR and weblogic[ Go to top ]

    Since i have defined the 2 ejbs through a CMR realtionship;my idea was that i need not put any additional QL for that.
    The relationship as defined in ejb-jar has alreayd been posted in the original post