cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Direct mapping between Named query and Pojo
Date Wed, 03 Mar 2010 15:33:37 GMT
On Tue, Mar 2, 2010 at 11:30 PM, Sudheer <sudheer.tech@gmail.com> wrote:
> Assume that named query is on more than one table and has columns from more
> than one table. In this case we may not be having dataobject defined stright
> from tables. So can I create a dataobject that just maps to named query?

A DataObject needs to be associated with a single table.  Of course,
it can have relationships to other tables.  If you really need to have
a DataObject associated with multiple tables and your database
supports views, then you can create a view that you map to your
DataObject.

> If my query is fixed, I will keep it in datamap and pass the runtime
> parameter values. But I am more interested in dynamic where condition
> constructed on existing named query. For e.g. Take a case of filter on list
> of objects (as mentioned above, object contains columns from mutiple
> tables). After user keys in the filter criteria, I need to constrict a
> dynamic where condition and link to existing named query.

I'm not sure if this really answers your question, but Cayenne by
default will omit (thereby widening the search) portions of the query
that are missing.  If you have:

firstName = $firstName and lastName = $lastName

and you only provide the query with the $lastName substitution
parameter, then Cayenne drops the firstName = $firstName part of the
query for you.

mrg

Mime
View raw message