Class Panache


  • public class Panache
    extends Object
    Utility class for Panache.
    Author:
    Stéphane Épardaud
    • Constructor Summary

      Constructors 
      Constructor Description
      Panache()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int executeUpdate​(String query, Parameters params)
      Executes a database update operation and return the number of rows operated on.
      static int executeUpdate​(String query, Object... params)
      Executes a database update operation and return the number of rows operated on.
      static int executeUpdate​(String query, Map<String,​Object> params)
      Executes a database update operation and return the number of rows operated on.
      static void flush()
      Flushes all pending changes to the database using the default entity manager.
      static void flush​(Class<?> clazz)
      Flushes all pending changes to the database using the entity manager for the given entity
      static void flush​(String persistenceUnit)
      Flushes all pending changes to the database using the entity manager for the given persistence unit
      static javax.persistence.EntityManager getEntityManager()
      Returns the default EntityManager
      static javax.persistence.EntityManager getEntityManager​(Class<?> clazz)
      Returns the EntityManager for the given entity
      static javax.persistence.EntityManager getEntityManager​(String persistenceUnit)
      Returns the EntityManager for the given persistence unit
      static javax.transaction.TransactionManager getTransactionManager()
      Returns the current TransactionManager
      static void setRollbackOnly()
      Marks the current transaction as "rollback-only", which means that it will not be committed: it will be rolled back at the end of this transaction lifecycle.
    • Constructor Detail

      • Panache

        public Panache()
    • Method Detail

      • getEntityManager

        public static javax.persistence.EntityManager getEntityManager()
        Returns the default EntityManager
        Returns:
        EntityManager
      • getEntityManager

        public static javax.persistence.EntityManager getEntityManager​(Class<?> clazz)
        Returns the EntityManager for the given entity
        Parameters:
        clazz - the entity class corresponding to the entity manager persistence unit.
        Returns:
        EntityManager
      • getEntityManager

        public static javax.persistence.EntityManager getEntityManager​(String persistenceUnit)
        Returns the EntityManager for the given persistence unit
        Parameters:
        persistenceUnit - the persistence unit for this entity manager.
        Returns:
        EntityManager
      • getTransactionManager

        public static javax.transaction.TransactionManager getTransactionManager()
        Returns the current TransactionManager
        Returns:
        the current TransactionManager
      • executeUpdate

        public static int executeUpdate​(String query,
                                        Object... params)
        Executes a database update operation and return the number of rows operated on.
        Parameters:
        query - a normal HQL query
        params - optional list of indexed parameters
        Returns:
        the number of rows operated on.
      • executeUpdate

        public static int executeUpdate​(String query,
                                        Map<String,​Object> params)
        Executes a database update operation and return the number of rows operated on.
        Parameters:
        query - a normal HQL query
        params - Map of named parameters
        Returns:
        the number of rows operated on.
      • executeUpdate

        public static int executeUpdate​(String query,
                                        Parameters params)
        Executes a database update operation and return the number of rows operated on.
        Parameters:
        query - a normal HQL query
        params - Parameters of named parameters
        Returns:
        the number of rows operated on.
      • setRollbackOnly

        public static void setRollbackOnly()
        Marks the current transaction as "rollback-only", which means that it will not be committed: it will be rolled back at the end of this transaction lifecycle.
      • flush

        public static void flush()
        Flushes all pending changes to the database using the default entity manager.
      • flush

        public static void flush​(Class<?> clazz)
        Flushes all pending changes to the database using the entity manager for the given entity
        Parameters:
        clazz - the entity class corresponding to the entity manager persistence unit.
      • flush

        public static void flush​(String persistenceUnit)
        Flushes all pending changes to the database using the entity manager for the given persistence unit
        Parameters:
        persistenceUnit - the persistence unit for this entity manager.