Class JPQLQueryHelper


  • public class JPQLQueryHelper
    extends Object
    This helper can perform various operations over a JPQL query.
    Since:
    2.5
    Version:
    2.5
    Author:
    Pascal Filion
    • Constructor Detail

      • JPQLQueryHelper

        public JPQLQueryHelper()
        Creates a new JPQLQueryHelper which uses the latest JPQL grammar.
    • Method Detail

      • getClassDescriptors

        public List<ClassDescriptor> getClassDescriptors​(CharSequence jpqlQuery,
                                                         AbstractSession session)
        Retrieves the list of descriptors corresponding to the entities used throughout the given JPQL query.
        Parameters:
        jpqlQuery - The JPQL query used to gather the descriptors defined in the declaration clause
        session - The AbstractSession is used to retrieve the descriptors
        Returns:
        The list of descriptors used in the JPQL query or an empty list if the JPQL query is invalid or incomplete
      • getConstructorQueryMappings

        public List<ConstructorQueryMappings> getConstructorQueryMappings​(AbstractSession session)
        Retrieves the class names and the attribute names mapped to their types that are used in the constructor expressions defined in the SELECT clause.

        For instance, from the following JPQL query:

         SELECT new test.example.Employee(e.name, e.id),
                new test.example.Address(a.zipcode)
         FROM Employee e, Address a

        The return object is

         |- test.example.Employee
         |-   |- name : String
         |-   |- id : int
         |- test.example.Address
              |- zipcode : int
        Parameters:
        session - The AbstractSession is used to retrieve the mappings used in the constructor items
        Returns:
        The holder of the result
      • getConstructorQueryMappings

        public ConstructorQueryMappings getConstructorQueryMappings​(AbstractSession session,
                                                                    DatabaseQuery query)
        Retrieves the class names and the attribute names mapped to their types that are used in the constructor expressions defined in the SELECT clause.

        For instance, from the following JPQL query:

         SELECT new test.example.Address(a.streetName, a.zipcode)
         FROM Address a

        The return object is

         test.example.Address
            |- BasicMapping(streetName) : String
            |- BasicMapping(zipcode) : int
        Parameters:
        session - The AbstractSession is used to retrieve the mappings used in the constructor items
        Returns:
        The holder of the result
      • getGrammar

        public JPQLGrammar getGrammar()
        Returns the JPQL grammar that will be used to define how to parse a JPQL query.
        Returns:
        The grammar that will determine how to parse a JPQL query