public class JPAUtil extends Object
Modifier and Type | Field and Description |
---|---|
private static ThreadLocal<EntityManager> |
em |
private static Properties |
emfProperties |
private static Map<String,EntityManagerFactory> |
factories |
private static org.apache.commons.logging.Log |
log |
Constructor and Description |
---|
JPAUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
close()
This method closes all EntityManagerFactory objects and clears them
from the cache.
|
static void |
closeEntityManager() |
static EntityManager |
getEntityManager() |
static EntityManager |
getEntityManager(String puName) |
static EntityManagerFactory |
getEntityManagerFactory(String puName)
This method will create or return the EntityManagerFactory for
the specified persistence unit.
|
static EntityManager |
peekEntityManager()
This method just allows the caller to look at entity manager to see
if it is currently set.
|
static void |
setEntityManager(EntityManager emgr) |
static void |
setEntityManagerFactoryProperties(Properties props)
This method defines the properties to pass to createEntityManagerFactory
|
private static final org.apache.commons.logging.Log log
private static final Map<String,EntityManagerFactory> factories
private static ThreadLocal<EntityManager> em
private static Properties emfProperties
public static void setEntityManagerFactoryProperties(Properties props)
public static EntityManagerFactory getEntityManagerFactory(String puName)
puName
- matches value in persistence.xmlpublic static void setEntityManager(EntityManager emgr)
public static EntityManager getEntityManager(String puName)
public static EntityManager getEntityManager()
public static EntityManager peekEntityManager()
public static void closeEntityManager()
public static void close()
Copyright © 2015 John's Hopkins University, Engineering Programs for Professionals. All rights reserved.