users@glassfish.java.net

Re: TopLink thread deadlock re UserTransaction.commit() in message-driven

From: <glassfish_at_javadesktop.org>
Date: Tue, 06 Nov 2007 08:51:07 PST

Here's the code for persistAndUpdatePrimaryKey(). We were calling the flush() method
since at the time that was how we were able to get the generated primary key updated
in the entity. I will follow up later today with the actual entity classes involved. I have to
trim them down a bit for confidentiality reasons.

    /**
     * Add the PortProfileRequest to persistent storage. This method ensures that
     * the primary key is updated in the given PortProfileRequest. This will
     * only work properly from the Local interface since the PortProfileRequest
     * is passed by reference.
     *
     * @param portProfileRequest the PortProfileRequest to add
     */
    public void persistAndUpdatePrimaryKey(PortProfileRequest portProfileRequest) throws PersistenceException
    {
        em.persist(portProfileRequest);
        em.flush();
    }

The em variable is declared as:

    @PersistenceContext
    private EntityManager em;
[Message sent by forum member 'skalynuk' (skalynuk)]

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