users@glassfish.java.net

Re: Persistence Glassfish RESOURCE_LOCAL

From: <glassfish_at_javadesktop.org>
Date: Mon, 27 Jul 2009 11:21:36 PDT

Thanks for your help.

But when is RESOURCE_LOCAL needed? When is it helpful I mean. Isn't JTA always the better solution.

Also, i wasn't aware of this kind of lookup you are citing: em = ic.lookup(".../mypu");

I'm only aware of the kind of lookup mentioned here: http://weblogs.java.net/blog/ss141213/archive/2005/12/dont_use_persis_1.html

PersistenceContext(name="persistence/LogicalName", unitName="ActualPUNameAsItAppearsInPersistence.xml")
public class RegistrationServlet extends HttpServlet {
   @Resource private UserTransaction utx;
   public void service ( HttpServletRequest req , HttpServletResponse resp)
        throws ServletException, IOException {
      Context envCtx = InitialContext().lookup("java:comp/env");
      EntityManager em = (EntityManager) envCtx.lookup("persistence/LogicalName");
      ...


or



 < persistence-context-ref>
   < persistence-context-ref-name>
       persistence/LogicalName
   </persistence-context-ref>
   < persistence-unit-name>
       ActualPUNameAsItAppearsInPersistence.xml
   </persistence-unit-name>
</persistence-context-ref>



Is your example different? It might be useful, so i'm asking.
[Message sent by forum member 'vladbalan' (vladbalan)]

http://forums.java.net/jive/thread.jspa?messageID=357747