fabio martelli created OPENJPA-2302:
---------------------------------------

             Summary: Slice support for QueryCompilationCache
                 Key: OPENJPA-2302
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2302
             Project: OpenJPA
          Issue Type: Improvement
          Components: slice
    Affects Versions: 2.2.1, 2.3.0
            Reporter: fabio martelli
             Fix For: 2.3.0


It seems that slice doesn't support QueryCompilationCache.
By running the following test case ...

public class TestQueryCompilationCache extends SliceTestCase {

    /**
     * Specify persistence unit name as System property
     * <code>-Dunit</code> or use the default value as
     * <code>"slice"</code>.
     */
    protected String getPersistenceUnitName() {
        return System.getProperty("unit", "slice");
    }

    @Override
    public void setUp() {
        super.setUp(PObject.class,
                "openjpa.QueryCompilationCache", "true");
    }

    public void testQueryCompilationCache()
            throws Exception {

        OpenJPAEntityManager em = emf.createEntityManager();

        em.getTransaction().begin();
        em.createQuery("SELECT o from PObject o").getResultList();
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        em.createQuery("SELECT o from PObject o").getResultList();
        em.close();

        emf.close();
    }
}

The following exception will be raised.

testQueryCompilationCache(org.apache.openjpa.slice.TestQueryCompilationCache)  
Time elapsed: 1.923 sec  <<< ERROR!
<openjpa-2.3.0-SNAPSHOT-r422266:1416742 nonfatal general error> 
org.apache.openjpa.persistence.PersistenceException: The context has been 
closed.  The stack trace at which the context was closed is available if 
Runtime=TRACE logging is enabled.
        at 
org.apache.openjpa.slice.jdbc.DistributedStoreQuery$ParallelExecutor.executeQuery(DistributedStoreQuery.java:156)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
        at 
org.apache.openjpa.slice.DistributedQueryImpl.execute(DistributedQueryImpl.java:61)
        at 
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
        at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:286)
        at 
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
        at 
org.apache.openjpa.slice.TestQueryCompilationCache.testQueryCompilationCache(TestQueryCompilationCache.java:57)
        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:597)
        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.apache.openjpa.slice.PersistenceTestCase.run(PersistenceTestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        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:597)
        at 
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
        at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
        at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
        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:597)
        at 
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
        at 
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Caused by: <openjpa-2.3.0-SNAPSHOT-r422266:1416742 fatal user error> 
org.apache.openjpa.persistence.InvalidStateException: The context has been 
closed.  The stack trace at which the context was closed is available if 
Runtime=TRACE logging is enabled.
        at org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4683)
        at org.apache.openjpa.kernel.QueryImpl.assertOpen(QueryImpl.java:1700)
        at org.apache.openjpa.kernel.QueryImpl.isUnique(QueryImpl.java:453)
        at 
org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.calculateEagerMode(JDBCStoreQuery.java:483)
        at 
org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(JDBCStoreQuery.java:174)
        at 
org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeQuery(ExpressionStoreQuery.java:783)
        at 
org.apache.openjpa.slice.jdbc.DistributedStoreQuery$QueryExecutor.call(DistributedStoreQuery.java:273)
        at 
org.apache.openjpa.slice.jdbc.DistributedStoreQuery$QueryExecutor.call(DistributedStoreQuery.java:266)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:680)


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to