0 Replies Latest reply on Aug 23, 2012 8:37 AM by Bernhard Anzeletti

    How does CDI @Produce @PersistenceContext(Type=EXTENDED)?

    Bernhard Anzeletti Newbie

      Dear community,

      being quite a newbie to CDI I would like to ask the following question:

      I learned that it is a good idea to keep the EntityManager across various requests, ideally as long as a conversation (obvious reasons: 1) The entities stay managed and relations can be navigated during a whole conversation; 2) less database I/O needed). The means to do so is to annotate the EntityManager as @PersistenceContext(Type=EXTENDED). Injecting such an EntityManager into a, say, SFSB works perfectly fine. However, if I switch to CDI, I also switch to producer fields for the entity manager, which have the implicit @Dependent scope. Annotating such a producer field with @PersistenceContext(Type=EXTENDED) yields an error in GF3.1.

      Hmmm... did I misinterpret something at the conceptual level? How can I @Produce a @PersistenceContext(Type=EXTENDED) using CDI?

      Any help welcome!

      Kind regards, Bernhard