users@jpa-spec.java.net

[jpa-spec users] [jsr338-experts] add description of @PersistenceContexts to section 10.4.1 of the JPA 2.1 spec...

From: Scott Marlow <smarlow_at_redhat.com>
Date: Thu, 13 Sep 2012 08:37:02 -0400

Hi eg,

I don't see a description of @PersistenceContexts. Could we add a few
words about @PersistenceContexts to section 10.4.1?

http://www.oracle.com/technetwork/middleware/ias/toplink-jpa-annotations-096251.html
includes the following:

"
@PersistenceContexts

If you need to specify more than one @PersistenceContext, you must
specify all your persistence contexts using a single
@PersistenceContexts annotation.
"

The above link also has an example that would be nice to include:

@Stateless
@PersistenceContexts({
     @PersistenceContext(name="OrderEM"),
     @PersistenceContext(name="ItemEM")
})
public class OrderEntryBean implements OrderEntry {
     @Resource EJBContext ctx;
     public Customer getCustomer(int custID) {
         EntityManager em = (EntityManager)ctx.lookup("OrderEM");
         return em.find(Customer.class, custID);
     }
     public void enterItem(int orderID, Item newItem) {
         EntityManager em = (EntityManager)ctx.lookup("ItemEM");
     ...
     }
}