Class QueryDetails

    • Constructor Detail

      • QueryDetails

        public QueryDetails()
    • Method Detail

      • getAllQueryTables

        public java.util.List<DBRow> getAllQueryTables()

        Support DBvolution at Patreon

        Returns:
        the allQueryTables
      • getRequiredQueryTables

        public java.util.List<DBRow> getRequiredQueryTables()

        Support DBvolution at Patreon

        Returns:
        the requiredQueryTables
      • getOptionalQueryTables

        public java.util.List<DBRow> getOptionalQueryTables()

        Support DBvolution at Patreon

        Returns:
        the optionalQueryTables
      • getAssumedQueryTables

        public java.util.List<DBRow> getAssumedQueryTables()

        Support DBvolution at Patreon

        Returns:
        the assumedQueryTables
      • getOptions

        public QueryOptions getOptions()

        Support DBvolution at Patreon

        Returns:
        the options
      • getExtraExamples

        public java.util.List<DBRow> getExtraExamples()

        Support DBvolution at Patreon

        Returns:
        the extraExamples
      • getAllConditions

        public java.util.List<BooleanExpression> getAllConditions​(DBDatabase database)
        Get all conditions involved in this query.

        Support DBvolution at Patreon

        Parameters:
        database - the database
        Returns:
        all conditions in the query
      • getConditions

        public java.util.List<BooleanExpression> getConditions()

        Support DBvolution at Patreon

        Returns:
        the conditions
      • getExpressionColumns

        public java.util.Map<java.lang.Object,QueryableDatatype<?>> getExpressionColumns()

        Support DBvolution at Patreon

        Returns:
        the expressionColumns
      • getDBReportGroupByColumns

        public java.util.Map<java.lang.Object,DBExpression> getDBReportGroupByColumns()

        Support DBvolution at Patreon

        Returns:
        the dbReportGroupByColumns
      • getExistingInstances

        public java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,DBRow>> getExistingInstances()

        Support DBvolution at Patreon

        Returns:
        the existingInstances
      • setGroupByRequiredByAggregator

        public void setGroupByRequiredByAggregator​(boolean b)
        Set the requirement for a GROUP BY clause.
        Parameters:
        b - the setting required
      • isGroupedQuery

        public boolean isGroupedQuery()
        Return the requirement for a GROUP BY clause.

        Support DBvolution at Patreon

        Returns:
        TRUE if the GROUP BY clause is required, otherwise FALSE.
      • setSelectSQLClause

        public void setSelectSQLClause​(java.lang.String selectClause)
        Define the SELECT clause used during the query.
        Parameters:
        selectClause - the select clause to set
      • getSelectSQLClause

        public java.lang.String getSelectSQLClause()
        Get the SELECT clause used during the query.

        Support DBvolution at Patreon

        Returns:
        the SELECT clause defined earlier
      • getHavingColumns

        public BooleanExpression[] getHavingColumns()

        Support DBvolution at Patreon

        Returns:
        the havingColumns
      • setHavingColumns

        public void setHavingColumns​(BooleanExpression... havingColumns)
        Parameters:
        havingColumns - the havingColumns to set
      • setQueryType

        public void setQueryType​(QueryType queryType)
      • setOptions

        public void setOptions​(QueryOptions tempOptions)
      • getRawSQLClause

        public java.lang.String getRawSQLClause()
        Returns:
        the rawSQLClause
      • setRawSQLClause

        public void setRawSQLClause​(java.lang.String rawSQLClause)
        Parameters:
        rawSQLClause - the rawSQLClause to set
      • getResults

        public java.util.List<DBQueryRow> getResults()
        Returns:
        the results
      • setResults

        public void setResults​(java.util.List<DBQueryRow> results)
        Parameters:
        results - the results to set
      • getResultSQL

        public java.lang.String getResultSQL()
        Returns:
        the resultSQL
      • setResultSQL

        public void setResultSQL​(java.lang.String resultSQL)
        Parameters:
        resultSQL - the resultSQL to set
      • getResultsPageIndex

        public java.lang.Integer getResultsPageIndex()
        Returns:
        the resultsPageIndex
      • setResultsPageIndex

        public void setResultsPageIndex​(java.lang.Integer resultsPageIndex)
        Parameters:
        resultsPageIndex - the resultsPageIndex to set
      • getResultsRowLimit

        public java.lang.Integer getResultsRowLimit()
        Returns:
        the resultsRowLimit
      • setResultsRowLimit

        public void setResultsRowLimit​(java.lang.Integer resultsRowLimit)
        Parameters:
        resultsRowLimit - the resultsRowLimit to set
      • clearResults

        public void clearResults()
      • getCount

        public java.lang.Long getCount()
      • setSortOrder

        public void setSortOrder​(SortProvider[] sortColumns)
      • setSortOrder

        public void setSortOrder​(ColumnProvider[] sortColumns)
      • blankResults

        public void blankResults()
      • addToSortOrder

        public void addToSortOrder​(SortProvider[] sortColumns)
      • clearSortOrder

        public void clearSortOrder()
      • needsResults

        public boolean needsResults​(QueryOptions options)
      • query

        public DBQueryable query​(DBDatabase db)
                          throws java.sql.SQLException,
                                 AccidentalBlankQueryException
        Description copied from interface: DBQueryable
        Performs the DB query and returns a list of all actions performed in the process.

        The supplied row will be changed by the action in an appropriate way, however the Action will contain an unchanged and unchangeable copy of the row for internal use.

        Specified by:
        query in interface DBQueryable
        Parameters:
        db - the target database.

        Support DBvolution at Patreon

        Returns:
        The complete list of all actions performed to complete this action on the database
        Throws:
        java.sql.SQLException - Database operations may throw SQLExceptions
        AccidentalBlankQueryException
      • willCreateBlankQuery

        public boolean willCreateBlankQuery​(DBDatabase db)
      • getResultSetForSQL

        protected java.sql.ResultSet getResultSetForSQL​(DBStatement statement,
                                                        java.lang.String sql)
                                                 throws java.sql.SQLException,
                                                        java.sql.SQLTimeoutException
        Executes the query using the statement provided and returns the ResultSet
        Parameters:
        statement - dbStatement
        sql - sql

        Support DBvolution at Patreon

        Returns:
        the ResultSet returned from the actual database. Database exceptions may be thrown
        Throws:
        java.sql.SQLException - java.sql.SQLException
        java.sql.SQLTimeoutException - time out exception
      • setQueryRowFromResultSet

        public void setQueryRowFromResultSet​(DBDefinition defn,
                                             java.sql.ResultSet resultSet,
                                             QueryDetails details,
                                             DBQueryRow queryRow,
                                             boolean isGroupedQuery)
                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setFieldsFromColumns

        protected void setFieldsFromColumns​(DBDefinition defn,
                                            DBRow oldInstance,
                                            DBRow newInstance,
                                            java.sql.ResultSet resultSet)
                                     throws java.sql.SQLException
        Based on the template provided by oldInstance, fill all the fields of newInstance with data from the current row of the ResultSet.

        OldInstance is used to find the selected properties, newInstance is the result, and restultSet contains the retrieved data. Database exceptions may be thrown

        Parameters:
        defn - the database definition
        oldInstance - oldInstance
        newInstance - newInstance
        resultSet - resultSet
        Throws:
        java.sql.SQLException - java.sql.SQLException
      • setExistingInstancesForTable

        protected java.util.Map<java.lang.String,DBRow> setExistingInstancesForTable​(java.util.Map<java.lang.String,DBRow> existingInstancesOfThisTableRow,
                                                                                     DBRow newInstance)
        Creates the list of already created rows for the DBRow class supplied.
        Parameters:
        existingInstancesOfThisTableRow - existingInstancesOfThisTableRow
        newInstance - newInstance

        Support DBvolution at Patreon

        Returns:
        a list of existing rows.
      • getOrSetExistingInstanceForRow

        protected DBRow getOrSetExistingInstanceForRow​(DBDefinition defn,
                                                       DBRow newInstance,
                                                       java.util.Map<java.lang.String,DBRow> existingInstancesOfThisTableRow)
        Retrieves or sets the existing instance of the DBRow provided.

        Queries maintain a list of existing rows to avoid duplicating identical rows. This method checks to see if the supplied row already exists and returns the existing version.

        If the row is new then this method stores it, and returns it as the existing instance.

        Parameters:
        defn - the database definition
        newInstance - newInstance
        existingInstancesOfThisTableRow - existingInstancesOfThisTableRow

        Support DBvolution at Patreon

        Returns:
        the exisinting instance of the provided row, or the row itself if none exists.
      • setCurrentPage

        protected void setCurrentPage​(java.util.List<DBQueryRow> results)
      • getCurrentPage

        public java.util.List<DBQueryRow> getCurrentPage()
      • clear

        public void clear()
      • setTimeoutInMilliseconds

        public void setTimeoutInMilliseconds​(java.lang.Long milliseconds)
      • setTimeoutInMilliseconds

        public void setTimeoutInMilliseconds​(java.lang.Integer milliseconds)
      • setTimeoutToDefault

        public void setTimeoutToDefault()
      • setTimeoutToForever

        public void setTimeoutToForever()
      • getTimeoutInMilliseconds

        public java.lang.Long getTimeoutInMilliseconds()
        Returns:
        the timeoutInMilliseconds
      • setLabel

        public void setLabel​(java.lang.String newLabel)
      • getLabel

        public java.lang.String getLabel()