Class ExtractExpression

  • All Implemented Interfaces:
    Expression

    public final class ExtractExpression
    extends AbstractSingleEncapsulatedExpression
    The EXTRACT function extracts a date part from a date/time value. The date part can be YEAR, MONTH, DAY, HOUR, MINUTE, SECOND. Some databases may support other parts.
    BNF: extract_expression ::= EXTRACT(date_part_literal [FROM] scalar_expression)

    date_part_literal ::= { MICROSECOND | SECOND | MINUTE | HOUR | DAY | WEEK | MONTH | QUARTER | YEAR | SECOND_MICROSECOND | MINUTE_MICROSECOND | MINUTE_SECOND | HOUR_MICROSECOND | HOUR_SECOND | HOUR_MINUTE | DAY_MICROSECOND | DAY_SECOND | DAY_MINUTE | DAY_HOUR | YEAR_MONTH, etc }

    Since:
    2.4
    Version:
    2.5
    Author:
    James Sutherland
    • Constructor Detail

      • ExtractExpression

        public ExtractExpression​(AbstractExpression parent)
        Creates a new ExtractExpression.
        Parameters:
        parent - The parent of this expression
    • Method Detail

      • getActualFromIdentifier

        public java.lang.String getActualFromIdentifier()
        Returns the actual FROM identifier found in the string representation of the JPQL query, which has the actual case that was used.
        Returns:
        The FROM identifier that was actually parsed, or an empty string if it was not parsed
      • getDatePart

        public java.lang.String getDatePart()
        Returns the date part that was parsed, it is used to extract a single part of a date/time, such as year, month, day, your, etc.
        Returns:
        The part of the date/time to retrieve
      • hasDatePart

        public boolean hasDatePart()
        Determines whether the date part literal was parsed or not.
        Returns:
        true if the date part literal was parsed; false otherwise
      • hasFrom

        public boolean hasFrom()
        Determines whether the identifier FROM was part of the query.
        Returns:
        true if the identifier FROM was parsed; false otherwise
      • hasSpaceAfterDatePart

        public boolean hasSpaceAfterDatePart()
        Determines whether a whitespace was found after the date part literal.
        Returns:
        true if there was a whitespace after the date part literal; false otherwise
      • hasSpaceAfterFrom

        public boolean hasSpaceAfterFrom()
        Determines whether a whitespace was found after FROM.
        Returns:
        true if there was a whitespace after FROM; false otherwise