[
https://issues.jboss.org/browse/CDI-523?page=com.atlassian.jira.plugin.sy...
]
Martin Andersson updated CDI-523:
---------------------------------
Description:
Section "3.5.2. Declaring a disposer method" has this example:
{code:java}
public class Resources {
@PersistenceContext
@Produces @UserDatabase
private EntityManager em;
public void close(@Disposes @UserDatabase EntityManager em) {
em.close();
}
}
{code}
The disposer method above call {{EntityManager.close()}} on a container-managed entity
manager which result in an {{IllegalStateException}} being thrown *and* the entity manager
remains open. This behavior is expected as the JPA specification forbids application code
to close a container-managed entity manager. JPA 2.1, section "7.9.1 Container
Responsibilities" says:
{quote}
The container must throw the IllegalStateException if the application calls
EntityManager.close on a container-managed entity manager.
{quote}
This has been proved
[
here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...]
and a theoretical walkthough surrounding entity managers combined with CDI scopes is
available
[
here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...].
was:
Section "3.5.2. Declaring a disposer method" has this example:
{code:java}
public class Resources {
@PersistenceContext
@Produces @UserDatabase
private EntityManager em;
public void close(@Disposes @UserDatabase EntityManager em) {
em.close();
}
}
{code}
The disposer method above call {{EntityManager.close()}} on a container-managed entity
manager which result in an {{IllegalStateException}} being thrown *and* the entity manager
remains open. This is expected as the JPA spec forbids application code to close a
container-managed entity manager. JPA 2.1, section "7.9.1 Container
Responsibilities" says:
{quote}
The container must throw the IllegalStateException if the application calls
EntityManager.close on a container-managed entity manager.
{quote}
This has been proved
[
here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...]
and a theoretical walkthough surrounding entity managers combined with CDI scopes is
available
[
here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...].
CDI spec tries to dispose a container-managed entity manager.
-------------------------------------------------------------
Key: CDI-523
URL:
https://issues.jboss.org/browse/CDI-523
Project: CDI Specification Issues
Issue Type: Bug
Affects Versions: 1.2.Final, 1.1.Final
Reporter: Martin Andersson
Section "3.5.2. Declaring a disposer method" has this example:
{code:java}
public class Resources {
@PersistenceContext
@Produces @UserDatabase
private EntityManager em;
public void close(@Disposes @UserDatabase EntityManager em) {
em.close();
}
}
{code}
The disposer method above call {{EntityManager.close()}} on a container-managed entity
manager which result in an {{IllegalStateException}} being thrown *and* the entity manager
remains open. This behavior is expected as the JPA specification forbids application code
to close a container-managed entity manager. JPA 2.1, section "7.9.1 Container
Responsibilities" says:
{quote}
The container must throw the IllegalStateException if the application calls
EntityManager.close on a container-managed entity manager.
{quote}
This has been proved
[
here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...]
and a theoretical walkthough surrounding entity managers combined with CDI scopes is
available
[
here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/maste...].
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)