Package net.hironico.common.entities
Class EntitiesUtils
java.lang.Object
net.hironico.common.entities.EntitiesUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidremoveEntities(javax.persistence.EntityManager entityManager, Object... entities) REmoves all provided entities into a SINGLE transaction.static voidremoveEntity(javax.persistence.EntityManager entityManager, Object entity) static <T> List<T>saveEntities(javax.persistence.EntityManager entityManager, T... entities) Saves the entity into the database using commit transaction if possible. the transaction scope is the whole set of given entities.static <T> TsaveEntity(javax.persistence.EntityManager entityManager, T entity) Saves the entity into the database using commit transaction if possible.
-
Constructor Details
-
EntitiesUtils
public EntitiesUtils()
-
-
Method Details
-
saveEntities
public static <T> List<T> saveEntities(javax.persistence.EntityManager entityManager, T... entities) throws Exception Saves the entity into the database using commit transaction if possible. the transaction scope is the whole set of given entities. If one fails then the whole bathc will be rollbacked.- Parameters:
entityManager- properly initialized entity managerentities- one or more entity to persist in the DB.- Returns:
- merged entities in a list.
- Throws:
Exception- in case of any problem
-
saveEntity
public static <T> T saveEntity(javax.persistence.EntityManager entityManager, T entity) throws Exception Saves the entity into the database using commit transaction if possible.- Parameters:
entityManager- properly initialized entity managerentity- entity object to save into database.- Returns:
- merged entity
- Throws:
Exception- in case of any problem
-
removeEntity
public static void removeEntity(javax.persistence.EntityManager entityManager, Object entity) throws Exception - Throws:
Exception
-
removeEntities
public static void removeEntities(javax.persistence.EntityManager entityManager, Object... entities) throws Exception REmoves all provided entities into a SINGLE transaction.- Parameters:
entityManager- the entitiy manager to useentities- list of entities to delete in the database.- Throws:
Exception- in case of problem
-