Query Issues

From: Eric Polino (eri..ampgroundautomation.com)
Date: Tue Jun 17 2008 - 12:48:05 EDT

  • Next message: Mike Kienenberger: "Re: Query Issues"

    Alright, I'm using SQLTemplate to do a query and I'm having issues
    when Cayenne tries to map it to a java object. The db entity is
    called Site, but the java entity is called DBSite. This is because we
    have a java class called Site that is a simple bean that we use to
    send across our WS layer.

    /* Java Code */
        String sql = "select * from Site where " +
          "siteType = (select typeid from SiteType where
    typeName='$SITETYPE') and " +
          "campground = $CAMPGROUND and " +
          "not exists (select * from Reservation where site=Site.siteId
    and campground=$CAMPGROUND and " +
                      "checkInDate < '$CHECKOUT' and checkOutDate > '$CHECKIN')";
        SQLTemplate tmpl = new SQLTemplate(DBSite.class, sql);
        tmpl.setParameters(params);
        List<DBSite> sites = context.performQuery(tmpl);

    /* Backtrace */

    [#|2008-06-17T11:28:34.415-0400|INFO|sun-appserver9.1|org.apache.cayenne.access.QueryLogger|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;|---
    will run 1 query.|#]

    [#|2008-06-17T11:28:34.416-0400|INFO|sun-appserver9.1|org.apache.cayenne.access.QueryLogger|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;|---
    transaction started.|#]

    [#|2008-06-17T11:28:34.562-0400|INFO|sun-appserver9.1|org.apache.cayenne.access.QueryLogger|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;|select
    * from Site where siteType = (select typeid from SiteType where
    typeName='Sniper Range') and campground = 4 and not exists (select *
    from Reservation where site=Site.siteId and campground=4 and
    checkInDate < '2008-12-18' and checkOutDate > '2008-12-01')|#]

    [#|2008-06-17T11:28:34.646-0400|INFO|sun-appserver9.1|org.apache.cayenne.access.QueryLogger|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;|===
    returned 3 rows. - took 84 ms.|#]

    [#|2008-06-17T11:28:34.647-0400|INFO|sun-appserver9.1|org.apache.cayenne.access.QueryLogger|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;|+++
    transaction committed.|#]

    [#|2008-06-17T11:28:34.674-0400|SEVERE|sun-appserver9.1|com.sun.xml.ws.server.sei.EndpointMethodHandler|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=dd5b3326-7115-4b3c-87d1-beb96d64e025;|[v.3.0M2
    Oct 23 2007 13:00:44] Null value for 'siteId'. Snapshot:
    org.apache.cayenne.DataRo..00e1b3c[values={SITEDESC=Sniper Range 1,
    SITEBASICRATE=30.0, SITENAME=sniper1, SITENOTES=, CAMPGROUND=4,
    SITEID=105, SITELENGTH=null, SITETYPE=12},
    version=-9223372036854775550, replaces=-9223372036854775808]. Prefix:
    null
    org.apache.cayenne.CayenneRuntimeException: [v.3.0M2 Oct 23 2007
    13:00:44] Null value for 'siteId'. Snapshot:
    org.apache.cayenne.DataRo..00e1b3c[values={SITEDESC=Sniper Range 1,
    SITEBASICRATE=30.0, SITENAME=sniper1, SITENOTES=, CAMPGROUND=4,
    SITEID=105, SITELENGTH=null, SITETYPE=12},
    version=-9223372036854775550, replaces=-9223372036854775808]. Prefix:
    null
            at org.apache.cayenne.access.ObjectResolver.createObjectId(ObjectResolver.java:280)
            at org.apache.cayenne.access.ObjectResolver.objectFromDataRow(ObjectResolver.java:206)
            at org.apache.cayenne.access.ObjectResolver.objectsFromDataRows(ObjectResolver.java:120)
            at org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows(ObjectResolver.java:100)
            at org.apache.cayenne.access.DataDomainQueryAction.interceptObjectConversion(DataDomainQueryAction.java:464)
            at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:129)
            at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:746)

    -- 
    Eric Polino
    Campground Automated Systems
    



    This archive was generated by hypermail 2.0.0 : Tue Jun 17 2008 - 12:48:38 EDT