users@glassfish.java.net

Re: EntityManager Lookup via jndi

From: <glassfish_at_javadesktop.org>
Date: Fri, 19 Dec 2008 12:43:24 PST

persistence.xml:

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="lmap-enterprise" transaction-type="JTA">
    <jta-data-source>jdbc/lmap-enterprise</jta-data-source>
  </persistence-unit>

-----------------------------------------------------------------

PatientServiceBean.java:

@Stateless
public class PatientServiceBean implements PatientServiceLocal {

  @Resource
  SessionContext context;

  public EntityManager getEm() {
    String persistenceContextRefName = "lmap-enterprise";
    return EntityManager.class.cast(
            context.lookup(persistenceContextRefName));
  }


Good Luck,
Vladimir
[Message sent by forum member 'vladperl' (vladperl)]

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