Return-Path: X-Original-To: apmail-openejb-commits-archive@www.apache.org Delivered-To: apmail-openejb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CD1477456 for ; Tue, 29 Nov 2011 11:00:01 +0000 (UTC) Received: (qmail 88649 invoked by uid 500); 29 Nov 2011 11:00:01 -0000 Delivered-To: apmail-openejb-commits-archive@openejb.apache.org Received: (qmail 88598 invoked by uid 500); 29 Nov 2011 11:00:01 -0000 Mailing-List: contact commits-help@openejb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openejb.apache.org Delivered-To: mailing list commits@openejb.apache.org Received: (qmail 88591 invoked by uid 99); 29 Nov 2011 11:00:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 11:00:01 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 11:00:00 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 04292A6AAB for ; Tue, 29 Nov 2011 10:59:40 +0000 (UTC) Date: Tue, 29 Nov 2011 10:59:40 +0000 (UTC) From: "Romain Manni-Bucau (Closed) (JIRA)" To: commits@openejb.apache.org Message-ID: <1726248787.21567.1322564380018.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <989884493.13224.1299844619655.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Closed] (OPENEJB-1443) EntityManager in non-transactional business methods using queries can be used only once MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OPENEJB-1443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Romain Manni-Bucau closed OPENEJB-1443. --------------------------------------- Resolution: Fixed Fix Version/s: 4.0-beta-2 should be ok on trunk > EntityManager in non-transactional business methods using queries can be used only once > --------------------------------------------------------------------------------------- > > Key: OPENEJB-1443 > URL: https://issues.apache.org/jira/browse/OPENEJB-1443 > Project: OpenEJB > Issue Type: Bug > Components: integration > Affects Versions: 3.1.4 > Reporter: David Allen > Fix For: 4.0-beta-2 > > > A call without any transaction on a business method which does not require a transaction cannot use the EntityManager after making a query. The Query object is wrapped by JtaQuery which closes the EntityManager after any call to the object. The following is an example that does not work when called outside of any transaction, where em is the injected EntityManager: > @TransactionAttribute(TransactionAttributeType.SUPPORTS) > public City getCity(String cityName) { > Query query = null; > query = em.createNamedQuery("City.RetrieveCityByName"); > query.setParameter(1, cityName); > if (!query.getResultList().isEmpty()) > --> return (City) query.getResultList().get(0); > else > throw new RuntimeException("Cannot locate a city named " + > cityName); > } > The first call to getResultList() is OK, but the second call fails because it already closed the EntityManager. The following stack trace excerpt shows the stack in OpenEJB during the second call to getResultList(): > Caused by: java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager. > at org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpen(EntityManagerImpl.java:1516) > at org.eclipse.persistence.internal.jpa.EntityManagerImpl.close(EntityManagerImpl.java:1380) > at org.apache.openejb.persistence.JtaQuery.getResultList(JtaQuery.java:45) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira