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?
-
CMR and weblogic (2 messages)
- Posted by: rana nag
- Posted on: June 13 2005 07:34 EDT
Threaded Messages (2)
- CMR and weblogic by sawan parihar on June 15 2005 23:47 EDT
- CMR and weblogic by rana nag on June 16 2005 00:48 EDT
-
CMR and weblogic[ Go to top ]
- Posted by: sawan parihar
- Posted on: June 15 2005 23:47 EDT
- in response to rana nag
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 -
CMR and weblogic[ Go to top ]
- Posted by: rana nag
- Posted on: June 16 2005 00:48 EDT
- in response to rana nag
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