Re: errors with derby and hsqldb (i need to switch from mysql to an embedded db)

From: Steave (stefanonafet..mail.com)
Date: Thu Sep 18 2008 - 14:51:57 EDT

  • Next message: Scott Anderson: "RE: errors with derby and hsqldb (i need to switch from mysql to an embedded db)"

    Sorry, I think i've missed the point, the exception occour in this method:

    public class CayenneCanvassDao [ ... ]
    public Canvass lastCanvass()
    {
          SQLTemplate template = new SQLTemplate(CayCanvass.class, "select *
    from Canvass c where c.id = (select MAX(c.id) from Canvass c)");

            List<CayCanvass> res =
    (List<CayCanvass>)getDataContext().performQuery(template);
            if ( res.size() == 1)
                return res.get(0);

            return null;
    }
    [...]

    May be that the SQLTemplate ("select * from Canvass c where c.id = (select
    MAX(c.id) from Canvass c)") is not compatible with hsqldb and derby?
    It is strange, because the query logger tells that it's ok:

    INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - ---
    transaction started.
    INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - select *
    from Canvass c where c.id = (select MAX(c.id) from Canvass c)
    INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - ===
    returned 1 row. - took 6 ms.
    INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - +++
    transaction committed.

    So in dubt...

    2008/9/18 Steave <stefanonafet..mail.com>

    > Hello,
    >
    > I've written a little app wich use cayenne.
    > I have (quite the same) the following runtime exception using Derby and
    > hsqldb, but not using MySql.
    > The exception is absolutely not clear to me, than please could someone
    > explain me where I'm doing wrong???
    >
    > Some notes:
    > 1 - I'm using a custom DataSourceFactory cause I've done some little
    > integration with Spring framework (inject the datasource during startup),
    > I think it is not the problem (I can post the class if you need)
    > 2 - I'm using dbcp to pool connections (may be that dbcp give problems with
    > embedded dbs? I don't think ... )
    >
    > the datasource url:
    > jdbc:hsqldb:file:/Users/steeve_work/hsqldbs/canvassManagerdb
    > The exception is thrown after the commit, the select statement returns one
    > row as expected
    >
    > Ah, this is the method:
    >
    > public class CayenneCanvassDao [ ... ]
    >
    > public List<Canvass> getCanvasses()
    > {
    > SelectQuery q = new SelectQuery(CayCanvass.class);
    > Ordering o = new Ordering("db:id", Ordering.ASC);
    > q.addOrdering(o);
    > return (List<Canvass>)getDataContext().performQuery(q);
    > }
    > [ ... ]
    >
    > CayCanvass extends auto._CayCanvass and implements Canvass (i've done some
    > abstractions :-) )
    >
    > Sorry for my BAD engish :-)
    > MANY MANY MANY THANKS!!!!!
    >
    > PS, if you need more details, please ask for it!
    >
    > [the stack trace]
    > INFO main org.apache.cayenne.conf.RuntimeLoadDelegate - started
    > configuration loading.
    > INFO main org.apache.cayenne.conf.RuntimeLoadDelegate - loaded domain:
    > CanvassDomain
    > INFO main org.apache.cayenne.conf.RuntimeLoadDelegate - loaded <map
    > name='CanvassDomainMap' location='CanvassDomainMap.map.xml'>.
    > INFO main org.apache.cayenne.conf.RuntimeLoadDelegate - loading <node
    > name='CanvassDomainNode' datasource='CanvassDomainNode.driver.xml'
    > factory='org.apache.cayenne.conf.DriverDataSourceFactory'>.
    > INFO main org.apache.cayenne.conf.RuntimeLoadDelegate - using factory:
    > com.steeve.canvassmanager.orm.cayenne.utils.DataSourceFactoryImpl
    > INFO main org.apache.cayenne.conf.RuntimeLoadDelegate - loaded datasource.
    > INFO main org.apache.cayenne.conf.RuntimeLoadDelegate - loaded map-ref:
    > CanvassDomainMap.
    > INFO main org.apache.cayenne.conf.RuntimeLoadDelegate - finished
    > configuration loading in 107 ms.
    > [...]
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - --- will
    > run 1 query.
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - ---
    > transaction started.
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - SELECT
    > t0.title, t0.id FROM Canvass t0 ORDER BY t0.id - prepared in 34 ms.
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - ===
    > returned 1 row. - took 83 ms.
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - +++
    > transaction committed.
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - --- will
    > run 1 query.
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - ---
    > transaction started.
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - select *
    > from Canvass c where c.id = (select MAX(c.id) from Canvass c)
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - ===
    > returned 1 row. - took 6 ms.
    > INFO http-8080-Processor24 org.apache.cayenne.access.QueryLogger - +++
    > transaction committed.
    > ERROR http-8080-Processor24
    > org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/GWTCanvassManager]
    > - Exception while dispatching incoming RPC call
    > java.lang.RuntimeException:
    > com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public
    > abstract java.util.List
    > com.steeve.canvassmanager.gwt.client.rpc.CanvassServices.listCanvasses()'
    > threw an unexpected exception: org.apache.cayenne.CayenneRuntimeException:
    > [v.2.0.4 October 8 2007] Null value for 'id'. Snapshot:
    > org.apache.cayenne.DataRo..5a397[values={TITLE=asd, ID=200},
    > version=-9223372036854775806, replaces=-9223372036854775808]. Prefix: null
    > at
    > org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleExporterProcessingException(GWTRPCServiceExporter.java:344)
    > at
    > org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:313)
    > at
    > com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
    > at
    > org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleRequest(GWTRPCServiceExporter.java:363)
    > at
    > org.springframework.web.context.support.HttpRequestHandlerServlet.service(HttpRequestHandlerServlet.java:63)
    > at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    > at
    > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    > at
    > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    > at
    > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    > at
    > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    > at
    > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    > at
    > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    > at
    > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    > at
    > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    > at
    > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    > at
    > org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    > at
    > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    > at
    > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    > at
    > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    > at java.lang.Thread.run(Thread.java:613)
    > Caused by: com.google.gwt.user.server.rpc.UnexpectedException: Service
    > method 'public abstract java.util.List
    > com.steeve.canvassmanager.gwt.client.rpc.CanvassServices.listCanvasses()'
    > threw an unexpected exception: org.apache.cayenne.CayenneRuntimeException:
    > [v.2.0.4 October 8 2007] Null value for 'id'. Snapshot:
    > org.apache.cayenne.DataRo..5a397[values={TITLE=asd, ID=200},
    > version=-9223372036854775806, replaces=-9223372036854775808]. Prefix: null
    > at
    > com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:360)
    > at
    > org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleInvocationTargetException(GWTRPCServiceExporter.java:215)
    > at
    > org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:304)
    > ... 18 more
    > Caused by: org.apache.cayenne.CayenneRuntimeException: [v.2.0.4 October 8
    > 2007] Null value for 'id'. Snapshot: org.apache.cayenne.DataRo..5a397[values={TITLE=asd,
    > ID=200}, version=-9223372036854775806, replaces=-9223372036854775808].
    > Prefix: null
    > at
    > org.apache.cayenne.access.ObjectResolver.createObjectId(ObjectResolver.java:254)
    > at
    > org.apache.cayenne.access.ObjectResolver.objectFromDataRow(ObjectResolver.java:196)
    > at
    > org.apache.cayenne.access.ObjectResolver.objectsFromDataRows(ObjectResolver.java:117)
    > at
    > org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows(ObjectResolver.java:97)
    > at
    > org.apache.cayenne.access.DataDomainQueryAction.interceptObjectConversion(DataDomainQueryAction.java:319)
    > at
    > org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:116)
    > at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:746)
    > at
    > org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:217)
    > at
    > org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:54)
    > at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1395)
    > at
    > org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1384)
    > at
    > com.steeve.canvassmanager.dao.cayenne.CayenneCanvassDao.lastCanvass(CayenneCanvassDao.java:58)
    > at
    > com.steeve.canvassmanager.gwt.server.rpc.CanvassServicesImpl.listCanvasses(CanvassServicesImpl.java:72)
    > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    > at
    > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    > at
    > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    > at java.lang.reflect.Method.invoke(Method.java:585)
    > at
    > org.gwtwidgets.server.spring.GWTRPCServiceExporter.invokeMethodOnService(GWTRPCServiceExporter.java:148)
    > at
    > org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:298)
    > ... 18 more
    >



    This archive was generated by hypermail 2.0.0 : Thu Sep 18 2008 - 14:52:29 EDT