SQLTemplate for not object queries and NullPointerException

From: Evgeny Ryabitskiy (evgeny.ryabitski..mail.com)
Date: Mon Dec 07 2009 - 05:52:15 EST

  • Next message: Michael Gentry: "December 2009 Board Report"

    Today I tried to use SQLTemplate for not object query (expecting to
    get list of DataRows).

    Here is what I did:

        public void testSQLTemplateForDataMapWithInsert() {
            DataMap testDataMap = context.getEntityResolver().getDataMap("testmap");
            String sql = "INSERT INTO ARTIST VALUES (15, 'Surikov', null)";
            SQLTemplate q1 = new SQLTemplate(testDataMap, sql);
            context.performNonSelectingQuery(q1);

            SQLTemplate q2 = new SQLTemplate(testDataMap, "SELECT * FROM ARTIST");
            List<DataRow> result = context.performQuery(q2);
            assertEquals(1, result.size());
        }

    I got :

    java.lang.NullPointerException
            at org.apache.cayenne.access.ObjectResolver.<init>(ObjectResolver.java:60)
            at org.apache.cayenne.access.DataDomainQueryAction$ObjectConversionStrategy.toObjects(DataDomainQueryAction.java:568)
            at org.apache.cayenne.access.DataDomainQueryAction$SingleObjectConversionStrategy.convert(DataDomainQueryAction.java:603)
            at org.apache.cayenne.access.DataDomainQueryAction.interceptObjectConversion(DataDomainQueryAction.java:451)
            at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:125)
            at org.apache.cayenne.access.UnitTestDomainQueryAction.execute(UnitTestDomainQueryAction.java:48)
            at org.apache.cayenne.access.UnitTestDomain.onQuery(UnitTestDomain.java:63)
            at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:335)
            at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:96)
            at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1049)
            at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1038)
            at org.apache.cayenne.query.SQLTemplateTest.testSQLTemplateForDataMapWithInsert(SQLTemplateTest.java:64)
            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 junit.framework.TestCase.runTest(TestCase.java:154)
            at junit.framework.TestCase.runBare(TestCase.java:127)
            at junit.framework.TestResult$1.protect(TestResult.java:106)
            at junit.framework.TestResult.runProtected(TestResult.java:124)
            at junit.framework.TestResult.run(TestResult.java:109)
            at junit.framework.TestCase.run(TestCase.java:118)
            at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
            at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

    Going to create JIRA issue for it...

    Evgeny.



    This archive was generated by hypermail 2.0.0 : Mon Dec 07 2009 - 05:52:51 EST