public class JPAService extends Object implements Service, Instrumentable
JPAExecutor
.Modifier and Type | Class and Description |
---|---|
static class |
JPAService.QueryEntry<E extends Enum<E>> |
Modifier and Type | Field and Description |
---|---|
static String |
CONF_CONN_DATA_SOURCE |
static String |
CONF_CONN_PROPERTIES |
static String |
CONF_CREATE_DB_SCHEMA |
static String |
CONF_DB_SCHEMA |
static String |
CONF_DRIVER |
static String |
CONF_MAX_ACTIVE_CONN |
static String |
CONF_OPENJPA_BROKER_IMPL |
static String |
CONF_PASSWORD |
static String |
CONF_PREFIX |
static String |
CONF_URL |
static String |
CONF_USERNAME |
static String |
CONF_VALIDATE_DB_CONN |
static String |
CONF_VALIDATE_DB_CONN_EVICTION_INTERVAL |
static String |
CONF_VALIDATE_DB_CONN_EVICTION_NUM |
static long |
DEFAULT_INITIAL_WAIT_TIME |
static int |
DEFAULT_MAX_RETRY_COUNT |
static long |
DEFAULT_MAX_WAIT_TIME |
static String |
INITIAL_WAIT_TIME |
static String |
MAX_RETRY_COUNT |
static String |
MAX_WAIT_TIME |
static String |
SKIP_COMMIT_FAULT_INJECTION_CLASS |
DEFAULT_LOCK_TIMEOUT, lockTimeout
Constructor and Description |
---|
JPAService() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy the JPAService
|
<T> T |
execute(JPAExecutor<T> executor)
Execute a
JPAExecutor . |
void |
executeBatchInsertUpdateDelete(Collection<JsonBean> insertBeans,
List<JPAService.QueryEntry> updateQueryList,
Collection<JsonBean> deleteBeans,
javax.persistence.EntityManager em)
Execute multiple update/insert queries in one transaction
|
Object |
executeGet(String namedQueryName,
javax.persistence.Query query,
javax.persistence.EntityManager em)
Execute a SELECT query
|
List<?> |
executeGetList(String namedQueryName,
javax.persistence.Query query,
javax.persistence.EntityManager em)
Execute a SELECT query to get list of results
|
int |
executeUpdate(String namedQueryName,
javax.persistence.Query query,
javax.persistence.EntityManager em)
Execute an UPDATE query
|
javax.persistence.EntityManager |
getEntityManager()
Return an EntityManager.
|
Class<? extends Service> |
getInterface()
Return the public interface of the service.
|
void |
init(Services services)
Initializes the
JPAService . |
void |
instrument(Instrumentation instr)
Set the system instrumentation.
|
public static final long DEFAULT_INITIAL_WAIT_TIME
public static final long DEFAULT_MAX_WAIT_TIME
public static final int DEFAULT_MAX_RETRY_COUNT
public static final String CONF_DB_SCHEMA
public static final String CONF_PREFIX
public static final String CONF_URL
public static final String CONF_DRIVER
public static final String CONF_USERNAME
public static final String CONF_PASSWORD
public static final String CONF_CONN_DATA_SOURCE
public static final String CONF_CONN_PROPERTIES
public static final String CONF_MAX_ACTIVE_CONN
public static final String CONF_CREATE_DB_SCHEMA
public static final String CONF_VALIDATE_DB_CONN
public static final String CONF_VALIDATE_DB_CONN_EVICTION_INTERVAL
public static final String CONF_VALIDATE_DB_CONN_EVICTION_NUM
public static final String CONF_OPENJPA_BROKER_IMPL
public static final String INITIAL_WAIT_TIME
public static final String MAX_WAIT_TIME
public static final String MAX_RETRY_COUNT
public static final String SKIP_COMMIT_FAULT_INJECTION_CLASS
public JPAService()
public Class<? extends Service> getInterface()
getInterface
in interface Service
JPAService
.public void instrument(Instrumentation instr)
Instrumentable
instrument
in interface Instrumentable
instr
- system instrumentation.public void init(Services services) throws ServiceException
JPAService
.init
in interface Service
services
- services instance.ServiceException
- thrown if the service could not initialize.public <T> T execute(JPAExecutor<T> executor) throws JPAExecutorException
JPAExecutor
.executor
- JPAExecutor to execute.JPAExecutorException
- thrown if an jpa executor failedpublic int executeUpdate(String namedQueryName, javax.persistence.Query query, javax.persistence.EntityManager em) throws JPAExecutorException
namedQueryName
- the name of query to be executedquery
- query instance to be executedem
- Entity ManagerJPAExecutorException
public void executeBatchInsertUpdateDelete(Collection<JsonBean> insertBeans, List<JPAService.QueryEntry> updateQueryList, Collection<JsonBean> deleteBeans, javax.persistence.EntityManager em) throws JPAExecutorException
insertBeans
- list of beans to be insertedupdateQueryList
- list of update queriesdeleteBeans
- list of beans to be deletedem
- Entity ManagerJPAExecutorException
public Object executeGet(String namedQueryName, javax.persistence.Query query, javax.persistence.EntityManager em) throws JPAExecutorException
namedQueryName
- the name of query to be executedquery
- query instance to be executedem
- Entity ManagerJPAExecutorException
public List<?> executeGetList(String namedQueryName, javax.persistence.Query query, javax.persistence.EntityManager em) throws JPAExecutorException
namedQueryName
- the name of query to be executedquery
- query instance to be executedem
- Entity ManagerJPAExecutorException
public javax.persistence.EntityManager getEntityManager()
Copyright © 2018 Apache Software Foundation. All rights reserved.