Class CountQuery

All Implemented Interfaces:
Query, SelectQuery

public class CountQuery extends AbstractSelectQuery
A query that counts the number of rows that would be returned by a SELECT statement.

This class extends AbstractSelectQuery to provide functionality for transforming a SELECT query into a COUNT query. It uses the database dialect to transform the SQL node for counting.

  • Field Details

    • sqlNode

      protected SqlNode sqlNode
      The SQL node representing the original SELECT query.
  • Constructor Details

    • CountQuery

      public CountQuery()
  • Method Details

    • isResultEnsured

      public boolean isResultEnsured()
      Returns whether the query is expected to return at least one result.
      Specified by:
      isResultEnsured in interface SelectQuery
      Overrides:
      isResultEnsured in class AbstractSelectQuery
      Returns:
      true if the query is expected to return at least one result
    • isResultMappingEnsured

      public boolean isResultMappingEnsured()
      Returns whether the result mapping is ensured.
      Specified by:
      isResultMappingEnsured in interface SelectQuery
      Overrides:
      isResultMappingEnsured in class AbstractSelectQuery
      Returns:
      true if the result mapping is ensured
    • getFetchType

      public FetchType getFetchType()
      Returns the fetch type for this query.
      Specified by:
      getFetchType in interface SelectQuery
      Overrides:
      getFetchType in class AbstractSelectQuery
      Returns:
      the fetch type
    • prepare

      public void prepare()
      Prepares this query for execution. This method must be called before the query is executed.

      This implementation prepares options and SQL.

      Specified by:
      prepare in interface Query
      Overrides:
      prepare in class AbstractSelectQuery
    • prepareSql

      protected void prepareSql()
      Prepares the SQL for this query.

      This method must be implemented by subclasses to build the SQL statement.

      Specified by:
      prepareSql in class AbstractSelectQuery
    • complete

      public void complete()
      Completes this query after execution. This method must be called after the query is executed.
    • setSqlNode

      public void setSqlNode(SqlNode sqlNode)
      Sets the SQL node representing the original SELECT query.
      Parameters:
      sqlNode - the SQL node