You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Abid Hussain <ab...@abid76.de> on 2006/05/24 23:14:56 UTC
retrieving fields and collections by ReportQuery
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.
Anybody got an idea what I can do?
Best regards,
Abid Hussain
--
Abid Hussain
Mail: abid.hussain@abid76.de
Web: http://www.abid76.de
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: retrieving fields and collections by ReportQuery
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi adid,
as carlos said, reportQueries are used to retrieve 'rows' not objects.
extending queryByCriteria to load only some attributes (fetch-groups in
jdo) is imo rather complicated. hibernate for example supports such lazy
attributes only by compiletime bytecode enhancement.
jakob
Abid Hussain schrieb:
> Hi again,
>
> first of all thanks for help.
>
> Using distinct would lead to following SQL:
> SELECT DISTINCT
> 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
> I think this wouldn't solve the problem, because the wanted behaviour is
> the following:
> Retrieving data same as in QueryByCriteria, including the retrieval of
> according collections, but retrieving only the fields/columns I actually
> need.
>
> It seems to be like Carlos said, one can't retrieve collections by using
> the ReportQuery.
>
> Isn't it a disadvantage that there is no possibility to restrict
> QueryByCriteria in the way that only the wanted fields/collections are
> retrieved?
> In most cases, I don't need all columns of a table. And it causes a
> great overhead, when I retrieve 30 columns but need only e.g. 3.
>
> Don't get me wrong, I think OJB is a great tool, and it helps me a lot.
>
> But wouldn't it be great having a method/class which combines the
> simplicity of QueryByCriteria and the flexibility of ReportQuery?
>
> Best regards,
>
> Abid
>
>
>
> Jakob Braeuchi schrieb:
>> hi abid,
>>
>> what about using distinct ?
>>
>> jakob
>>
>> Abid Hussain schrieb:
>>> 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: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: retrieving fields and collections by ReportQuery
Posted by Abid Hussain <ab...@abid76.de>.
Hi again,
first of all thanks for help.
Using distinct would lead to following SQL:
SELECT DISTINCT
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
I think this wouldn't solve the problem, because the wanted behaviour is
the following:
Retrieving data same as in QueryByCriteria, including the retrieval of
according collections, but retrieving only the fields/columns I actually
need.
It seems to be like Carlos said, one can't retrieve collections by using
the ReportQuery.
Isn't it a disadvantage that there is no possibility to restrict
QueryByCriteria in the way that only the wanted fields/collections are
retrieved?
In most cases, I don't need all columns of a table. And it causes a
great overhead, when I retrieve 30 columns but need only e.g. 3.
Don't get me wrong, I think OJB is a great tool, and it helps me a lot.
But wouldn't it be great having a method/class which combines the
simplicity of QueryByCriteria and the flexibility of ReportQuery?
Best regards,
Abid
Jakob Braeuchi schrieb:
> hi abid,
>
> what about using distinct ?
>
> jakob
>
> Abid Hussain schrieb:
>> 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: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
--
Abid Hussain
Mail: abid.hussain@abid76.de
Web: http://www.abid76.de
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: retrieving fields and collections by ReportQuery
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi abid,
what about using distinct ?
jakob
Abid Hussain schrieb:
> 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: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: retrieving fields and collections by ReportQuery
Posted by Carlos Chávez <cc...@agssa.net>.
Abid Hussain escribió:
> 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.
Hi Abid.
But that is the correct behavior for SQL.
I think the Report Query is not designed to get Persistence Object
in his result, i mean Module.class and ModuleDiscipline.class as an
attribute.
With the ReportQuery you can retrieve the columns or attributes
values. I never try get the collection as an attribute in the result.
With QueryByCriteria you can get Module.class object as you know and
then navigate over the disciplines collection using a Iterator.
every object in the collection are ModuleDiscipline.class so you can
access to the attributes and methods.
I don't know if this help you.
Cheers.
Carlos Chávez.
>
> 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: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: retrieving fields and collections by ReportQuery
Posted by Abid Hussain <ab...@abid76.de>.
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: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
--
Abid Hussain
Mail: abid.hussain@abid76.de
Web: http://www.abid76.de
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: retrieving fields and collections by ReportQuery
Posted by Carlos Chávez <cc...@agssa.net>.
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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org