Re: Getting complex queries in cayenne

From: Dhruti Ramani (dhrutiraman..ahoo.com)
Date: Fri May 06 2005 - 11:56:36 EDT

  • Next message: Andrus Adamchik: "Re: Getting complex queries in cayenne"

    I understand those concepts now. thanks.
     
    I tried the way you have suggested but still returns null values. Even if I am not using complex query just "select * from cahflow", it returns all rows with null value.
     
    Any ideal?
    Denna

    Cris Daniluk <cris.danilu..mail.com> wrote:
    > SQLTemplate query=new SQLTemplate(CashFlow.class,"select * from
    > cashflow",true);
    > String str="select c.paydate from cashflow c,quote q where
    > c.quote_id=q.quote_id AND q.isacceptedQuote='t' ";
    > query.setTemplate(DbAdapter.POSTGRES,str);
    > List results=dataContext.performQuery(query);
    >
    > It returns 5 rows which is true but if i try to print those values it
    > returns null for all rows.
    > Am I doing something wrong?

    I think so. I think you actually want:

    SQLTemplate query=new SQLTemplate(CashFlow.class,"select * from
    cashflow c,quote q where c.quote_id=q.quote_id AND
    q.isacceptedQuote='t'";
    List results=dataContext.performQuery(query);

    The query that is the second argument to SQLTemplate should be the
    default query you want to run, in the way you want to run it. The str
    that you were passing only returned the date, but it was the one that
    Cayenne was using (since you specified it as the query for the
    postgres adapter, which will override the default).

    I would only ever use setTemplate and override the default if your
    application needs to simultaneously support different databases.

    Cris

    ---------------------------------
    Do you Yahoo!?
    Read only the mail you want - Yahoo! Mail SpamGuard.

                    
    ---------------------------------
    Discover Yahoo!
     Stay in touch with email, IM, photo sharing & more. Check it out!



    This archive was generated by hypermail 2.0.0 : Fri May 06 2005 - 11:56:38 EDT