openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <>
Subject Set query params without TX?
Date Tue, 24 Apr 2007 22:03:57 GMT
I have some code that runs outside of a transaction which does  
basically the following:

     Query query = entityManager.createNamedQuery(name)
     query.setParameter(1, "foo");
     List results = query.getResultList();

If I don't set the parameter the code works fine (assuming the query  
didn't need a parameter), but when I set the parameter, I get the  
following exception:

Caused by: <0.9.7-incubating-SNAPSHOT fatal user error>  
org.apache.openjpa.persistence.InvalidStateException: The context has  
been closed.  The stack trace at which the context was closed is held  
in the embedded exception.
FailedObject: java.lang.IllegalStateException
	at org.apache.openjpa.kernel.BrokerImpl.assertOpen( 
	at org.apache.openjpa.kernel.QueryImpl.assertOpen(
	at org.apache.openjpa.kernel.DelegatingQuery.assertOpen 
	at org.apache.openjpa.persistence.QueryImpl.setParameter 
	at org.apache.openjpa.persistence.QueryImpl.setParameter 
	at org.apache.openejb.core.cmp.jpa.JpaCmpEngine.executeQuery 

Is this supposed to work?  If not, maybe we should throw the  
exception when getting the query.

In the mean time I'll code around this.


View raw message