Mapping aggregate queries...

From: I. Venuti (i.venut..aribel.it)
Date: Tue Feb 07 2006 - 07:59:40 EST

  • Next message: Gentry, Michael \(Contractor\): "RE: SQLTemplate / inExp"

    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+Queries
    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 - 07:59:44 EST