Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-3612

examples should demonstrate obtaining entity manager factory from JNDI via persistence unit reference

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 2.1.0.GA
    • Fix Version/s: 2.1.1.CR2
    • Component/s: Examples
    • Labels:
    • Estimated Difficulty:
      Medium

      Description

      For any example that is deploying to a standard Java EE 5 environment (for instance the jpa example deploying to GlassFish or JBoss AS 5), the entity manager factory should be obtained through JNDI through a persistence unit reference.

      5.3.1 of JPA spec:

      "Within a Java EE environment, an entity manager factory may be injected using the Persistence-Unit annotation or obtained through JNDI lookup."

      It would first need to be declared in web.xml:

      <persistence-unit-ref>
      <persistence-unit-ref-name>bookingDatabase/emf</persistence-unit-ref-name>
      <persistence-unit-name>bookingDatabase</persistence-unit-name>
      </persistence-unit-ref>

      Then the components.xml would look like this:

      <persistence:managed-persistence-context name="entityManager"
      auto-create="true"
      persistence-unit-jndi-name="java:comp/env/bookingDatabase/emf" />

      The reason we should do this is to advocate the Java EE standard approach.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dan.j.allen Dan Allen
                  Reporter:
                  dan.j.allen Dan Allen
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 4 hours
                    4h
                    Remaining:
                    Remaining Estimate - 4 hours
                    4h
                    Logged:
                    Time Spent - Not Specified
                    Not Specified