Re: retrieving fields and collections by ReportQuery
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: ... ... 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: retrieving fields and collections by ReportQuery
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: ... ... 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] - 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]
Re: retrieving fields and collections by ReportQuery
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: ... ... 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: retrieving fields and collections by ReportQuery
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: ... ... 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: retrieving fields and collections by ReportQuery
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: ... ... 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]
Re: retrieving fields and collections by ReportQuery
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: ... ... 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]
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: ... ... 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: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]