Class QueryUtil


  • public class QueryUtil
    extends java.lang.Object
    Utility methods for manipulating JPA and Hibernate query objects.
    Since:
    14.2.0
    Version:
    $Revision: 24978 $ $Date: 2022-05-02 16:46:33 -0300 (Mon, 02 May 2022) $
    • Method Detail

      • addDummyQuerySpace

        public static Query addDummyQuerySpace​(Query query)
        Adds a dummy query space to a JPA query created with EntityManager.createNativeQuery(java.lang.String). This is used to prevent the default behavior of the execution of a change SQL to invalidate all hibernate cache.
        Parameters:
        query - the query object.
        Returns:
        the query object given.
        Since:
        14.2.0
      • addDummyQuerySpace

        public static org.hibernate.SQLQuery addDummyQuerySpace​(org.hibernate.SQLQuery query)
        Adds a dummy query space to a SQLQuery. This is used to prevent the default behavior of the execution of a change SQL to invalidate all hibernate cache.
        Parameters:
        query - the query object.
        Returns:
        the query object given.
        Since:
        14.2.0
      • createSQLQueryWithDQS

        public static org.hibernate.SQLQuery createSQLQueryWithDQS​(java.lang.String sqlString)
        Creates a SQLQuery using the current transaction and adds a dummy query space to it.

        This is used to create a bulk change query that will not invalidate all hibernate cache.

        Parameters:
        sqlString - the SQL.
        Returns:
        the query.
        Since:
        14.2.0
      • createSQLQueryWithDQS

        public static org.hibernate.SQLQuery createSQLQueryWithDQS​(org.hibernate.Session session,
                                                                   java.lang.String sqlString)
        Creates a SQLQuery using the given session and adds a dummy query space to it.

        This is used to create a bulk change query that will not invalidate all hibernate cache.

        Parameters:
        session - the Hibernate session.
        sqlString - the SQL.
        Returns:
        the query.
        Since:
        14.2.0
      • createNativeQueryWithDQS

        public static Query createNativeQueryWithDQS​(java.lang.String sqlString)
        Creates a JPA native query using the current transaction and adds a dummy query space to it.

        This is used to create a bulk change query that will not invalidate all hibernate cache.

        Parameters:
        sqlString - the SQL.
        Returns:
        the query.
        Since:
        14.2.0
      • createNativeQueryWithDQS

        public static Query createNativeQueryWithDQS​(EntityManager em,
                                                     java.lang.String sqlString)
        Creates a JPA native query using the given entity manager and adds a dummy query space to it.

        This is used to create a bulk change query that will not invalidate all hibernate cache.

        Parameters:
        em - the entity manager.
        sqlString - the SQL.
        Returns:
        the query.
        Since:
        14.2.0