org.apache.oozie.service
Class JPAService

java.lang.Object
  extended by org.apache.oozie.service.JPAService
All Implemented Interfaces:
Service, Instrumentable

public class JPAService
extends Object
implements Service, Instrumentable

Service that manages JPA and executes JPAExecutor.


Nested Class Summary
static class JPAService.QueryEntry<E extends Enum<E>>
           
 
Field Summary
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_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
           
 
Fields inherited from interface org.apache.oozie.service.Service
DEFAULT_LOCK_TIMEOUT, lockTimeout, USE_XCOMMAND
 
Constructor Summary
JPAService()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONF_DB_SCHEMA

public static final String CONF_DB_SCHEMA
See Also:
Constant Field Values

CONF_PREFIX

public static final String CONF_PREFIX
See Also:
Constant Field Values

CONF_URL

public static final String CONF_URL
See Also:
Constant Field Values

CONF_DRIVER

public static final String CONF_DRIVER
See Also:
Constant Field Values

CONF_USERNAME

public static final String CONF_USERNAME
See Also:
Constant Field Values

CONF_PASSWORD

public static final String CONF_PASSWORD
See Also:
Constant Field Values

CONF_CONN_DATA_SOURCE

public static final String CONF_CONN_DATA_SOURCE
See Also:
Constant Field Values

CONF_CONN_PROPERTIES

public static final String CONF_CONN_PROPERTIES
See Also:
Constant Field Values

CONF_MAX_ACTIVE_CONN

public static final String CONF_MAX_ACTIVE_CONN
See Also:
Constant Field Values

CONF_CREATE_DB_SCHEMA

public static final String CONF_CREATE_DB_SCHEMA
See Also:
Constant Field Values

CONF_VALIDATE_DB_CONN

public static final String CONF_VALIDATE_DB_CONN
See Also:
Constant Field Values

CONF_VALIDATE_DB_CONN_EVICTION_INTERVAL

public static final String CONF_VALIDATE_DB_CONN_EVICTION_INTERVAL
See Also:
Constant Field Values

CONF_VALIDATE_DB_CONN_EVICTION_NUM

public static final String CONF_VALIDATE_DB_CONN_EVICTION_NUM
See Also:
Constant Field Values
Constructor Detail

JPAService

public JPAService()
Method Detail

getInterface

public Class<? extends Service> getInterface()
Return the public interface of the service.

Specified by:
getInterface in interface Service
Returns:
JPAService.

instrument

public void instrument(Instrumentation instr)
Description copied from interface: Instrumentable
Set the system instrumentation.

Specified by:
instrument in interface Instrumentable
Parameters:
instr - system instrumentation.

init

public void init(Services services)
          throws ServiceException
Initializes the JPAService.

Specified by:
init in interface Service
Parameters:
services - services instance.
Throws:
ServiceException - thrown if the service could not initialize.

destroy

public void destroy()
Destroy the JPAService

Specified by:
destroy in interface Service

execute

public <T> T execute(JPAExecutor<T> executor)
          throws JPAExecutorException
Execute a JPAExecutor.

Parameters:
executor - JPAExecutor to execute.
Returns:
return value of the JPAExecutor.
Throws:
JPAExecutorException - thrown if an jpa executor failed

executeUpdate

public int executeUpdate(String namedQueryName,
                         javax.persistence.Query query,
                         javax.persistence.EntityManager em)
                  throws JPAExecutorException
Execute an UPDATE query

Parameters:
namedQueryName - the name of query to be executed
query - query instance to be executed
em - Entity Manager
Returns:
Integer that query returns, which corresponds to the number of rows updated
Throws:
JPAExecutorException

executeBatchInsertUpdateDelete

public void executeBatchInsertUpdateDelete(Collection<JsonBean> insertBeans,
                                           List<JPAService.QueryEntry> updateQueryList,
                                           Collection<JsonBean> deleteBeans,
                                           javax.persistence.EntityManager em)
                                    throws JPAExecutorException
Execute multiple update/insert queries in one transaction

Parameters:
insertBeans - list of beans to be inserted
updateQueryList - list of update queries
deleteBeans - list of beans to be deleted
em - Entity Manager
Throws:
JPAExecutorException

executeGet

public Object executeGet(String namedQueryName,
                         javax.persistence.Query query,
                         javax.persistence.EntityManager em)
Execute a SELECT query

Parameters:
namedQueryName - the name of query to be executed
query - query instance to be executed
em - Entity Manager
Returns:
object that matches the query

executeGetList

public List<?> executeGetList(String namedQueryName,
                              javax.persistence.Query query,
                              javax.persistence.EntityManager em)
Execute a SELECT query to get list of results

Parameters:
namedQueryName - the name of query to be executed
query - query instance to be executed
em - Entity Manager
Returns:
list containing results that match the query

getEntityManager

public javax.persistence.EntityManager getEntityManager()
Return an EntityManager. Used by the StoreService. Once the StoreService is removed this method must be removed.

Returns:
an entity manager


Copyright © 2015 Apache Software Foundation. All Rights Reserved.