Class JPABusinessDataRepositoryImpl
java.lang.Object
org.bonitasoft.engine.business.data.impl.JPABusinessDataRepositoryImpl
- All Implemented Interfaces:
BusinessDataRepository,EntityManagerFactoryAware,SingleClassLoaderListener,LifecycleService,TenantLifecycleService
public class JPABusinessDataRepositoryImpl
extends Object
implements BusinessDataRepository, EntityManagerFactoryAware, SingleClassLoaderListener
Some of these methods are enriched with aspects to throw events. See BusinessDataRepositoryEventAspect for details.
- Author:
- Matthieu Chaffotte, Romain Bioteau
-
Constructor Summary
ConstructorsConstructorDescriptionJPABusinessDataRepositoryImpl(UserTransactionService transactionService, BusinessDataModelRepository businessDataModelRepository, Map<String, Object> configuration, ClassLoaderService classLoaderService) -
Method Summary
Modifier and TypeMethodDescription<T extends Serializable>
TFinds an Entity that is defined in a deployed Business Data Model, through JPQL query.protected <T extends Serializable>
Tfind(Class<T> resultClass, javax.persistence.TypedQuery<T> query, Map<String, Serializable> parameters) <T extends org.bonitasoft.engine.bdm.Entity>
TFinds an Entity that is defined in a deployed Business Data Model.<T extends org.bonitasoft.engine.bdm.Entity>
List<T>findByIdentifiers(Class<T> entityClass, List<Long> primaryKeys) Finds (well-loaded) entities that is defined in a deployed Business Data Model.<T extends org.bonitasoft.engine.bdm.Entity>
List<T>Finds entities that is defined in a deployed Business Data Model.<T extends Serializable>
TfindByNamedQuery(String queryName, Class<T> resultClass, Map<String, Serializable> parameters) <T extends Serializable>
List<T>findList(Class<T> resultClass, String jpqlQuery, Map<String, Serializable> parameters, int startIndex, int maxResults) protected <T extends Serializable>
List<T>findList(javax.persistence.TypedQuery<T> query, Map<String, Serializable> parameters, int startIndex, int maxResults) <T extends Serializable>
List<T>findListByNamedQuery(String queryName, Class<T> resultClass, Map<String, Serializable> parameters, int startIndex, int maxResults) Retrieves theSetof known Entity class names in this Business Data Repository.protected javax.persistence.EntityManagerjavax.persistence.EntityManagerFactoryorg.bonitasoft.engine.bdm.Entitymerge(org.bonitasoft.engine.bdm.Entity entity) Reconnect the given entity with the persistence unitvoidonUpdate(ClassLoader newClassLoader) voidpause()Temporary halt the execution of this service.voidpersist(org.bonitasoft.engine.bdm.Entity entity) Saves or updates an entity in the Business Data Repository.voidremove(org.bonitasoft.engine.bdm.Entity entity) Removes an entity from the Business Data Repository.voidresume()resume the execution the servicevoidstart()Start the servicevoidstop()org.bonitasoft.engine.bdm.Entityunwrap(org.bonitasoft.engine.bdm.Entity wrapped) Unwraps the Entity if necessary.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bonitasoft.engine.classloader.SingleClassLoaderListener
onDestroyMethods inherited from interface org.bonitasoft.engine.commons.TenantLifecycleService
init
-
Constructor Details
-
JPABusinessDataRepositoryImpl
public JPABusinessDataRepositoryImpl(UserTransactionService transactionService, BusinessDataModelRepository businessDataModelRepository, Map<String, Object> configuration, ClassLoaderService classLoaderService)
-
-
Method Details
-
start
public void start()Description copied from interface:LifecycleServiceStart the service- Specified by:
startin interfaceLifecycleService
-
stop
public void stop()- Specified by:
stopin interfaceLifecycleService
-
getEntityManagerFactory
public javax.persistence.EntityManagerFactory getEntityManagerFactory()- Specified by:
getEntityManagerFactoryin interfaceEntityManagerFactoryAware
-
pause
public void pause()Description copied from interface:LifecycleServiceTemporary halt the execution of this service.- Specified by:
pausein interfaceLifecycleService
-
resume
public void resume()Description copied from interface:LifecycleServiceresume the execution the service- Specified by:
resumein interfaceLifecycleService
-
getEntityClassNames
Description copied from interface:BusinessDataRepositoryRetrieves theSetof known Entity class names in this Business Data Repository.- Specified by:
getEntityClassNamesin interfaceBusinessDataRepository- Returns:
- the
Setof known Entity class names, as qualified class names.
-
getEntityManager
protected javax.persistence.EntityManager getEntityManager() -
findById
public <T extends org.bonitasoft.engine.bdm.Entity> T findById(Class<T> entityClass, Long primaryKey) throws SBusinessDataNotFoundException Description copied from interface:BusinessDataRepositoryFinds an Entity that is defined in a deployed Business Data Model.- Specified by:
findByIdin interfaceBusinessDataRepository- Parameters:
entityClass- the class of the entity to search for.primaryKey- the primary key to search by.- Returns:
- the found entity, if any.
- Throws:
SBusinessDataNotFoundException- if the Business Data could not be found with the provided primary key.
-
findByIds
public <T extends org.bonitasoft.engine.bdm.Entity> List<T> findByIds(Class<T> entityClass, List<Long> primaryKeys) Description copied from interface:BusinessDataRepositoryFinds entities that is defined in a deployed Business Data Model. If a primary key does not match an existing entity no exception is thrown and nothing is added in the list.- Specified by:
findByIdsin interfaceBusinessDataRepository- Parameters:
entityClass- the class of the entity to search for.primaryKeys- the primary keys.- Returns:
- the list of found entities
-
findByIdentifiers
public <T extends org.bonitasoft.engine.bdm.Entity> List<T> findByIdentifiers(Class<T> entityClass, List<Long> primaryKeys) Description copied from interface:BusinessDataRepositoryFinds (well-loaded) entities that is defined in a deployed Business Data Model. If a primary key does not match an existing entity no exception is thrown and nothing is added in the list.- Specified by:
findByIdentifiersin interfaceBusinessDataRepository- Parameters:
entityClass- the class of the entity to search for.primaryKeys- the primary keys.- Returns:
- the list of found entities
-
find
protected <T extends Serializable> T find(Class<T> resultClass, javax.persistence.TypedQuery<T> query, Map<String, Serializable> parameters) throws NonUniqueResultException- Throws:
NonUniqueResultException
-
find
public <T extends Serializable> T find(Class<T> resultClass, String jpqlQuery, Map<String, Serializable> parameters) throws NonUniqueResultExceptionDescription copied from interface:BusinessDataRepositoryFinds an Entity that is defined in a deployed Business Data Model, through JPQL query.- Specified by:
findin interfaceBusinessDataRepository- Parameters:
resultClass- the class of the entity to search for.jpqlQuery- the JPQL query string to search the entity.parameters- the parameters needed to execute the query.- Returns:
- the found entity, if any.
- Throws:
NonUniqueResultException- if more than one result was found.
-
findList
public <T extends Serializable> List<T> findList(Class<T> resultClass, String jpqlQuery, Map<String, Serializable> parameters, int startIndex, int maxResults) - Specified by:
findListin interfaceBusinessDataRepository
-
findByNamedQuery
public <T extends Serializable> T findByNamedQuery(String queryName, Class<T> resultClass, Map<String, Serializable> parameters) throws NonUniqueResultException- Specified by:
findByNamedQueryin interfaceBusinessDataRepository- Throws:
NonUniqueResultException
-
findListByNamedQuery
public <T extends Serializable> List<T> findListByNamedQuery(String queryName, Class<T> resultClass, Map<String, Serializable> parameters, int startIndex, int maxResults) - Specified by:
findListByNamedQueryin interfaceBusinessDataRepository
-
findList
protected <T extends Serializable> List<T> findList(javax.persistence.TypedQuery<T> query, Map<String, Serializable> parameters, int startIndex, int maxResults) -
remove
public void remove(org.bonitasoft.engine.bdm.Entity entity) Description copied from interface:BusinessDataRepositoryRemoves an entity from the Business Data Repository.- Specified by:
removein interfaceBusinessDataRepository- Parameters:
entity- the entity to remove.
-
persist
public void persist(org.bonitasoft.engine.bdm.Entity entity) Description copied from interface:BusinessDataRepositorySaves or updates an entity in the Business Data Repository.- Specified by:
persistin interfaceBusinessDataRepository- Parameters:
entity- the entity to save / update.
-
merge
public org.bonitasoft.engine.bdm.Entity merge(org.bonitasoft.engine.bdm.Entity entity) Description copied from interface:BusinessDataRepositoryReconnect the given entity with the persistence unit- Specified by:
mergein interfaceBusinessDataRepository- Parameters:
entity- the entity to reconnect.- Returns:
- the connected entity.
-
unwrap
public org.bonitasoft.engine.bdm.Entity unwrap(org.bonitasoft.engine.bdm.Entity wrapped) Description copied from interface:BusinessDataRepositoryUnwraps the Entity if necessary.- Specified by:
unwrapin interfaceBusinessDataRepository- Parameters:
wrapped- the potential wrapped entity- Returns:
- the unwrapped entity
-
onUpdate
- Specified by:
onUpdatein interfaceSingleClassLoaderListener
-