Re: Direct mapping between Named query and Pojo

From: Michael Gentry (mgentr..asslight.net)
Date: Wed Mar 03 2010 - 10:33:37 EST

  • Next message: Andrus Adamchik: "Re: Direct mapping between Named query and Pojo"

    On Tue, Mar 2, 2010 at 11:30 PM, Sudheer <sudheer.tec..mail.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



    This archive was generated by hypermail 2.0.0 : Wed Mar 03 2010 - 10:34:35 EST