Class JPQLQueryHelper


  • public class JPQLQueryHelper
    extends java.lang.Object
    JPQL query helper class providing key information about the language etc.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.String[] RESERVED_IDENTIFIERS
      List of identifier names not allowed by JPQL.
      (package private) static java.lang.String[] SINGLE_STRING_KEYWORDS
      Keywords used in single-string JPQL.
      (package private) static java.lang.String[] SINGLE_STRING_KEYWORDS_INCLUDING_RANGE
      JPQL single-string keywords when allowing RANGE.
    • Constructor Summary

      Constructors 
      Constructor Description
      JPQLQueryHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getEntityNameFromJPQLString​(java.lang.String query)
      Convenience method to extract the FROM candidate entity name from a JPQL query string.
      static java.lang.String getJPQLForExpression​(Expression expr)
      Convenience method to return the JPQL single-string query text for the provided expression.
      static boolean isKeyword​(java.lang.String name)
      Convenience method returning if the supplied name is a keyword for this query language.
      static boolean isKeyword​(java.lang.String name, boolean allowRange)
      Convenience method returning if the supplied name is a keyword for this query language (including RANGE).
      static boolean isReservedIdentifier​(java.lang.String name)
      Convenience method returning if the supplied name is a reserved identifier for this query language.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SINGLE_STRING_KEYWORDS

        static final java.lang.String[] SINGLE_STRING_KEYWORDS
        Keywords used in single-string JPQL. Uppercase variants specified here, but JPQL allows case-insensitive.
      • SINGLE_STRING_KEYWORDS_INCLUDING_RANGE

        static final java.lang.String[] SINGLE_STRING_KEYWORDS_INCLUDING_RANGE
        JPQL single-string keywords when allowing RANGE.
      • RESERVED_IDENTIFIERS

        static final java.lang.String[] RESERVED_IDENTIFIERS
        List of identifier names not allowed by JPQL.
    • Constructor Detail

      • JPQLQueryHelper

        public JPQLQueryHelper()
    • Method Detail

      • isKeyword

        public static boolean isKeyword​(java.lang.String name)
        Convenience method returning if the supplied name is a keyword for this query language.
        Parameters:
        name - Name to check
        Returns:
        Whether it is a keyword
      • isKeyword

        public static boolean isKeyword​(java.lang.String name,
                                        boolean allowRange)
        Convenience method returning if the supplied name is a keyword for this query language (including RANGE).
        Parameters:
        name - Name to check
        allowRange - Whether to allow RANGE syntax
        Returns:
        Whether it is a keyword
      • isReservedIdentifier

        public static boolean isReservedIdentifier​(java.lang.String name)
        Convenience method returning if the supplied name is a reserved identifier for this query language.
        Parameters:
        name - Name to check
        Returns:
        Whether it is a reserved identifier
      • getEntityNameFromJPQLString

        public static java.lang.String getEntityNameFromJPQLString​(java.lang.String query)
        Convenience method to extract the FROM candidate entity name from a JPQL query string.
        Parameters:
        query - The query string
        Returns:
        The candidate entity name
      • getJPQLForExpression

        public static java.lang.String getJPQLForExpression​(Expression expr)
        Convenience method to return the JPQL single-string query text for the provided expression.
        Parameters:
        expr - The expression
        Returns:
        The JPQL single-string text that equates to this expression