RE: Mapping aggregate queries...

From: Gentry, Michael \(Contractor\) ("Gentry,)
Date: Tue Feb 07 2006 - 10:30:58 EST

  • Next message: Cris Daniluk: "Re: SQLTemplate / inExp"

    Could you try doing a templ.setFetchingDataRows(true) before you do your
    performQuery()?

    -----Original Message-----
    From: I. Venuti [mailto:i.venut..aribel.it]
    Sent: Tuesday, February 07, 2006 8:00 AM
    To: cayenne-use..bjectstyle.org
    Subject: Mapping aggregate queries...

    Hi,

    I'm new to cayenne and I'm tring to figure out how to use it for queries

    that hasn't any direct-mapping with an object.
    In the page
    http://www.objectstyle.org/confluence/display/CAY/Mapping+Aggregate+Quer
    ies
    I've read:

    "1. /(recommended)/ Use SQLTemplate returning DataRows without
    converting them to objects. This is appropriate for most display
    operations that require data but not behavior."

    Unfortunatly I can't figure how to achieve this. Can you give me a
    direction for this? Thanks a lot.

    I'm using a web application and I've tried this query:

    in a .class:
        public List test(DataContext dc) throws Exception {
           
            org.objectstyle.cayenne.query.SQLTemplate templ =
                new org.objectstyle.cayenne.query.SQLTemplate(
                    
    (org.objectstyle.cayenne.map.DataMap)dc.getDataMaps().iterator().next(),
                    "SELECT descr_ita, descr FROM News, Autori WHERE
    Autori.id=news.id",
                    true);
            return dc.performQuery(templ);
        }

    NB: Autori.id isn't related with any db constraint to news.id; just a
    test!

    in a JSP:
       
    <%
        DataContext context =
    BasicServletConfiguration.getDefaultContext(session);
        List lris = nw.test(context);
        // Do nothing
    %>

    The error is:

     org.apache.jasper.JasperException: [v.1.1.3 September 28 2005] Can't
    instantiate DataObjects from resutls. ObjEntity is undefined for query:
    org.objectstyle.cayenne.query.SQLTemplat..b87f6

    -- Ivan



    This archive was generated by hypermail 2.0.0 : Tue Feb 07 2006 - 10:31:01 EST