[jboss-jira] [JBoss JIRA] (WFLY-6383) Entities using Extended PersistentContext are not managed

Rakesh K. Cherukuri (JIRA) issues at jboss.org
Wed Mar 16 12:51:00 EDT 2016


     [ https://issues.jboss.org/browse/WFLY-6383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rakesh K. Cherukuri updated WFLY-6383:
--------------------------------------
    Description: 
Entities using Extended PersistentContext are not managed in a Stateful bean.

Attached are the bean class and the client servlet class

  was:
Entities using Extended PersistentContext are not managed in a Stateful bean.

Bean Class:
-----------------
bq. @Stateful
bq. @SessionScoped
bq. @Local(CdiStatefulEmployeeService.class)
bq. public class CdiStatefulEmployeeBean implements CdiStatefulEmployeeService {
bq.   @PersistenceContext(name = "employees", type = PersistenceContextType.EXTENDED)
bq.   EntityManager extendedEm;
bq.   private Employee cached;
bq.   @Override
bq.   public String service() {
bq.     cached = extendedEm.find(Employee.class, 499983);
bq.     return cached.getFirstName();
bq.   }
bq.   @Override
bq.   public String updateEntity() {
bq.     cached.setFirstName("Uri2");
bq.     return cached.getFirstName();
bq.   }
bq. }

Client Servlet that basically invokes both service calls of the bean:
---------------------------------------------------------------------------------------
bq. @WebServlet("/atInjectedStatefulEjbClient")
bq. public class AtInjectedStatefulEjbClient extends HttpServlet {
bq. 
bq.   @Inject
bq.   CdiStatefulEmployeeService statefulBean;
bq. 
bq.   @Override
bq.   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
bq. 
bq.     HttpSession session = req.getSession(true);
bq.     resp.setContentType("text/plain");
bq. 
bq.     PrintWriter pw = resp.getWriter();
bq. 
bq.     pw.println(statefulBean.service());
bq.     pw.println();
bq.     pw.println(statefulBean.updateEntity());
bq.     
bq.     session.invalidate();
bq.     pw.flush();
bq.     pw.close();
bq.   }
bq. }



> Entities using Extended PersistentContext are not managed
> ---------------------------------------------------------
>
>                 Key: WFLY-6383
>                 URL: https://issues.jboss.org/browse/WFLY-6383
>             Project: WildFly
>          Issue Type: Bug
>          Components: EJB
>    Affects Versions: 10.0.0.Final
>         Environment: WildFLy 10.0.0.Final
> Mac
>            Reporter: Rakesh K. Cherukuri
>              Labels: Extended, JPA, Persistence, PersistenceContext
>
> Entities using Extended PersistentContext are not managed in a Stateful bean.
> Attached are the bean class and the client servlet class



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list