Hallo again,

thanks for the quick answer.

When I add disciplines.moduleName and disciplines.disciplineName as attributes for the ReportQuery it somehow works:
ReportQueryByCriteria q = QueryFactory.newReportQuery(Module.class,
                                crit);
q.addOrderByAscending("name");
q.setAttributes(new String[] {
"name", "courseOfStudy", "disciplines.moduleName", "disciplines.disciplineName" });

OJB generates following SQL:
SELECT A0.modul_Name,A0.Zuordnung,A0.Haeufigkeit,A1.MODUL_NAME,A1.BEREICH_NAME FROM MODUL A0 INNER JOIN MODUL_BEREICH A1 ON A0.modul_Name=A1.MODUL_NAME ORDER BY 1

But there is one major disadvantage about it: The retrieved Modules occure as often in the resulting collection as they are referenced in the ModuleDiscipline. E.g., when a Module has three according rows in the table ModuleDiscipline, it occurs three times in the result of the query above.

Maybe there is another way to fix this problem?

Best regards,

Abid Hussain

Carlos Chávez schrieb:
Abid Hussain escribió:
Hallo everybody,

for the following problem I didn't find a proper solution:
I'm using the ReportQuery to retrieve data, because the table has about 25 columns and i only need a few. The problem is, in the ReportQuery I can only specifiy the fields which I want to retrieve, but no collections.

I've got the following classes/tables:

<class-descriptor class="modulverwaltung.beans.ojb.Module"
    table="MODUL">
    <field-descriptor name="name" column="modul_Name"
        jdbc-type="VARCHAR" primarykey="true" />
    <field-descriptor name="courseOfStudy" column="Zuordnung"
        jdbc-type="VARCHAR" />
    ...
    ...
    <collection-descriptor name="disciplines"
    element-class-ref="modulverwaltung.beans.ojb.ModuleDiscipline"
        orderby="disciplineName" sort="ASC">
        <inverse-foreignkey field-ref="moduleName" />
    </collection-descriptor>
</class-descriptor>

<class-descriptor class="modulverwaltung.beans.ojb.ModuleDiscipline"
    table="MODUL_BEREICH">
    <field-descriptor name="moduleName" column="MODUL_NAME"
        jdbc-type="VARCHAR" primarykey="true" />
    <field-descriptor name="disciplineName" column="BEREICH_NAME"
        jdbc-type="VARCHAR" primarykey="true" />
</class-descriptor>

To retrieve date from the table MODUL, I could do like this:
QueryByCriteria q = new QueryByCriteria(Module.class, QueryByCriteria.CRITERIA_SELECT_ALL);
q.addOrderByAscending("name");
c = broker.getCollectionByQuery(q);

But then all the fields from the according table would be retrieved, whereas I only need two fields plus the specified collection.

On the other hand, when I use a ReportQuery in order to retrieve only the fields I actually need, I can't specify the collection in the ReportQuery.
Did you try disciplines.moduleName and disciplines.disciplineName as attributes for the ReportQuery ?

  Cheers,
  Carlos Chávez.

Anybody got an idea what I can do?

Best regards,

Abid Hussain



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--

Abid Hussain
Mail: [EMAIL PROTECTED]
Web: http://www.abid76.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to