hi frank,

no, read-only objects are not possible in ojb. 
but the view can be used to solve this problem.

jakob

> Hi Jacob,
> 
> Thank very much you for your examples.
> I have tried it and it works!
> But is it possible to define in the repository.xml a kind of read-only
> business object which
> can be used to read the results returned by a sql ?
> This read-only business object can contain columns of different tables
> (join!).
> 
> I have tried the following, but it doesn't work :
> 
> //************ In repository.xml ******************
> <!-- Mapping of User defined classes ends here -->
> <class-descriptor
>   class="com.minervasoftcare.lib.ojb.broker.View"
> >
>   <field-descriptor id="1"
>     name="articleName"
>     column="ARTICLENAME" 
>     jdbc-type="VARCHAR"
>   />
>   <field-descriptor id="2"
>     name="productName"
>     column="PRODUCTNAME"
>     jdbc-type="VARCHAR"
>   />
> </class-descriptor>
> 
> //******************** Code **************************
> Query query = QueryFactory.createQueryBySQL(View.class, "select
> CATEGORYNAME, ARTICLENAME from category, article where
> category.category_nr
> = article.category_nr");   
> Collection coll = broker.getCollectionByQuery(query);
> 
> 
> 
> Thanks,
> 
> Frank
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Jakob Braeuchi [mailto:[EMAIL PROTECTED]]
> Sent: woensdag 28 augustus 2002 20:44
> To: OJB Users List
> Subject: Re: join
> 
> 
> hi,
> 
> the following snippets show report queries in my test :
> 
> private void queryReport(PersistenceBroker broker)
> {
> ReportQueryByCriteria query;
> Criteria crit;
> System.out.println("\nreport (id,name,vorname,konti.saldo) with name like
> 'er%'");
> crit = new Criteria();
> crit.addEqualTo("name", "%er"); // uses Like
> crit.addOrderByAscending("geburtsDatum");
> query = new ReportQueryByCriteria(Person.class, crit);
> query.setColumns(new String[] { "id", "name", "vorname", "konti.saldo" });
> showReportResult(broker.getReportQueryIteratorByQuery(query));
> }
> 
> private void queryReport2(PersistenceBroker broker)
> {
> ReportQueryByCriteria query;
> Criteria crit;
> System.out.println("\nreport (sum(test) with name like '%er'");
> crit = new Criteria();
> crit.addEqualTo("name", "%er"); // uses Like
> query = new ReportQueryByCriteria(Person.class, crit);
> query.setColumns(new String[] { "sum(test)" });
> showReportResult(broker.getReportQueryIteratorByQuery(query));
> }
> 
> private void queryReport3(PersistenceBroker broker)
> {
> ReportQueryByCriteria query;
> Criteria crit;
> System.out.println("\nreport name, vorname, sum(konti.saldo)");
> crit = new Criteria();
> crit.addGroupBy(new String[] { "id", "name", "vorname" });
> query = new ReportQueryByCriteria(Person.class, crit);
> query.setColumns(new String[] { "id", "name", "vorname",
> "sum(konti.saldo)" });
> showReportResult(broker.getReportQueryIteratorByQuery(query));
> }
> 
> private void queryReportSql(PersistenceBroker broker)
> {
> Query query;
> String sql;
> System.out.println("\nreport sql (id,name,vorname) with name like '%er'");
> sql = "select id,vorname,name from tabPerson where name like '%er'";
> query = new QueryBySQL(Person.class, sql);
> showReportResult(broker.getReportQueryIteratorByQuery(query));
> }
> 
> hth
> jakob
> 
> ----- Original Message -----
> From: "Frank Renaers" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 28, 2002 5:44 PM
> Subject: join
> 
> 
> > Hi,
> >
> > In a report, I want to show information from 2 business objects.
> > There 's a 1-n relationship between the 2 objects.
> > ex. A category or productgroup can contain n articles and each article
> > belongs to 1 productgroup
> >
> > For performance reasons, I want to select the report data with 1 sql.
> > ex. select category.categoryname, article.articlename from category,
> article
> > where category.category_nr = article.category_nr
> >
> > Does someone know whether this is possible with a ReportQuery ?
> > Does someone have an example ?
> >
> > Thanks,
> >
> > Frank Renaers
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


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

Reply via email to