users@glassfish.java.net

Re: Issue with persistence context propagation: SFSB call SLSB

From: <glassfish_at_javadesktop.org>
Date: Mon, 15 Dec 2008 04:06:14 PST

I've found a solution. I simply added one line at the very beginning of the load() to trick the EJB container to create an extended PC, which is bound to the TX before it calls CustomerDAO.findCustomer(), like this

@TransactionAttribute(TransactionAttributeType.REQUIRED)
        public void load(PrintWriter out)
        {
                try {
                        [b]em.setFlushMode(FlushModeType.AUTO);[/b]
                        
                        customer = customerDAO.findCustomer(1);
                        //customer = (Customer) em.find(Customer.class, 1);
                        customerContained = em.contains(customer);
                        out.println("customer loaded: " + customer + ", " + customerContained);
                } catch (Exception ex) {
                        ex.printStackTrace();
                }
        }

Problem solved!
[Message sent by forum member 'anqingxu' (anqingxu)]

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