Class EntitiesUtils

java.lang.Object
net.hironico.common.entities.EntitiesUtils

public class EntitiesUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    removeEntities(javax.persistence.EntityManager entityManager, Object... entities)
    REmoves all provided entities into a SINGLE transaction.
    static void
    removeEntity(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.
    static <T> T
    saveEntity(javax.persistence.EntityManager entityManager, T entity)
    Saves the entity into the database using commit transaction if possible.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 manager
      entities - 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 manager
      entity - 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 use
      entities - list of entities to delete in the database.
      Throws:
      Exception - in case of problem