Hi,

> Hi Jens,
> 
> OJB defines a layer between my java app and a database. Since the 
> repositiory file contains a description of the tables and column 
> names I would think it to be bad design on my part if I repeated that
> information some-where hard-coded in my programm by doing a direct 
> sql using table & colum names.

there is sample code in PerformanceTestJdbcReferenceImpl that shows how OJB
metadata can be used to write and execute SQL queries in a clean way!

> 
> I could very well imagine an OJB function 
> int max( String fieldname, Class c),  after all
> int getCount( Query q) does exist !

getCount does exist for OJB internal purposes.

once we start to have max(), we'll get asked why is there no support for
avg(), etc.
There are also lots of SQL functions that are propietary for the different
RDBMS vendors.
IMO it's not a good idea to provide SQL functions on that level.

> > 
> > I don't know if this is possible with Ojb at all, since the 
> query you
> > mention has nothing to do with object mapping, it just 
> returns a single
> > value.
> > I usually use plain jdbc for such queries.

Of course you can use SQL functions within ordinary queries with
addSql(...). (see http://db.apache.org/ojb/query.html).
But the OJB query concept relies on materializing persistent entity objects,
not on returning resultsets!

If you want to work with resulsets instead with full entity objects use the
reportquery mechanism.

cheers,
Thomas


> 
> Any comments ?
> 
> Cheers,
>   Stefan
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to