Twease

edu.cornell.med.icb.persistence
Class JpaEmFactory

java.lang.Object
  extended by edu.cornell.med.icb.persistence.JpaEmFactory

public final class JpaEmFactory
extends Object

Factory for JPA Entity Managers for multiple (or one) persistence-unit names.

Author:
Kevin Dorff

Method Summary
static void close(String persistenceUnitName)
          Close a specific EntityManagerFactory that were opened by calling getEmFactory(...).
static void closeAll()
          Close all EntityManagerFactory's that were opened by calling getEmFactory(...).
static javax.persistence.EntityManagerFactory getEmFactory(String persistenceUnitName)
          Retrieve an entity manager factory for the persistence-unit.
static javax.persistence.EntityManager getEntityManager(String persistenceUnitName)
          Retrieve an EntityManager for the persistence-unit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEmFactory

public static javax.persistence.EntityManagerFactory getEmFactory(String persistenceUnitName)
Retrieve an entity manager factory for the persistence-unit. We will only obtain one of these per persistence-unit. NOTE: It is preferred to just call getEntityManager(persistenceUnitName). NOTE: When the application is finished it should call closeAll().

Parameters:
persistenceUnitName - name of the persistence-unit we want the EnitityManagerFactory for.
Returns:
the EnitityManagerFactory for the specified persistenceUnitName

getEntityManager

public static javax.persistence.EntityManager getEntityManager(String persistenceUnitName)
Retrieve an EntityManager for the persistence-unit. An EntityManager should be used for one unit of work. NOTE: When you are finished with the EntityManager you need to call .close() on it.

Parameters:
persistenceUnitName - name of the persistence-unit we want the EnitityManager for
Returns:
An EntityManager

close

public static void close(String persistenceUnitName)
Close a specific EntityManagerFactory that were opened by calling getEmFactory(...).

Parameters:
persistenceUnitName - name of the persistence-unit we want to close

closeAll

public static void closeAll()
Close all EntityManagerFactory's that were opened by calling getEmFactory(...).


Twease

Copyright © 2006-2007 Institute for Computational Biomedicine, All Rights Reserved.