Interface IDatabaseSearch


public interface IDatabaseSearch
Provides methods for searching and counting the persistent objects in the database.

SQL searches should only be used for advanced querying/counting when joins and the other SQL-capabilities, that cannot be achieved using Lucene queries, are needed. In other cases the IDataService's search/count methods that work with Lucene queries are preferred. For example, IDataService.searchInstances(String, String, String), IDataService.getInstancesCount(String, String), etc.

Since:
3.19.3
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    count(String sqlQuery)
    Returns the number of persistent objects found by executing the given SQL-query in the database for the current revision.
    int
    countInBaseline(String sqlQuery, String revision)
    Returns the number of persistent objects found by executing the specified SQL-query in the database for the specified revision.
    int
    countInCollection(String sqlQuery, IObjectId collectionId)
    Returns the count of persistent objects matching the specified SQL query in the Collection.
    <T extends IPObject>
    IPObjectList<T>
    instances(String sqlQuery)
    Searches the persistent objects by executing the specified SQL-query in the database for the current revision.
    <T extends IPObject>
    IPObjectList<T>
    instancesInBaseline(String sqlQuery, String revision)
    Searches the persistent objects by executing the specified SQL-query in the database for the specified revision.
    <T extends IPObject>
    IPObjectList<T>
    instancesInCollection(String sqlQuery, IObjectId collection)
    Executes an SQL query against the specified Collection to retrieve persistent objects.
  • Method Details

    • instances

      @NotNull <T extends IPObject> IPObjectList<T> instances(@NotNull String sqlQuery)
      Searches the persistent objects by executing the specified SQL-query in the database for the current revision.
      Parameters:
      sqlQuery -
      Returns:
      a list containing the objects found as a result of the query execution.
      See Also:
    • instancesInBaseline

      @NotNull <T extends IPObject> IPObjectList<T> instancesInBaseline(@NotNull String sqlQuery, @Nullable String revision)
      Searches the persistent objects by executing the specified SQL-query in the database for the specified revision.
      Parameters:
      sqlQuery -
      revision - A Baseline revision in which to search. If null, search in the current revision.
      Returns:
      a list containing the objects found as a result of the query execution.
      See Also:
    • instancesInCollection

      @NotNull <T extends IPObject> IPObjectList<T> instancesInCollection(@NotNull String sqlQuery, @NotNull IObjectId collection)
      Executes an SQL query against the specified Collection to retrieve persistent objects.

      Note: Queries executed against the Collection HEAD (without a specified revision in the Collection ID) may return slightly stale data (in the range of several minutes).

      For detailed information about Collection query syntax and best practices, please refer to the Polarion SDK documentation.

      Returns:
      a list containing the objects found as a result of the query execution.
      Since:
      3.25.6
    • count

      int count(@NotNull String sqlQuery)
      Returns the number of persistent objects found by executing the given SQL-query in the database for the current revision. Should be used instead of instances(String sqlQuery).size() when only the number of search results is required.
      Parameters:
      sqlQuery -
      Returns:
      The number of persistent objects that match the given SQL-query.
      See Also:
    • countInBaseline

      int countInBaseline(@NotNull String sqlQuery, @Nullable String revision)
      Returns the number of persistent objects found by executing the specified SQL-query in the database for the specified revision. Should be used instead of instancesInBaseline(String sqlQuery, String revision).size() when only the number or search results is required.
      Parameters:
      sqlQuery -
      revision - A Baseline revision in which to search. If null, search in the current revision.
      Returns:
      The number of persistent objects that match the given SQL-query.
      See Also:
    • countInCollection

      int countInCollection(@NotNull String sqlQuery, @NotNull IObjectId collectionId)
      Returns the count of persistent objects matching the specified SQL query in the Collection. This method is optimized for counting and should be preferred over instancesInCollection(String, IObjectId) when only the result count is needed.

      Note: Queries executed against the Collection HEAD (without a specified revision in the Collection ID) may return slightly stale data (in the range of several minutes).

      For detailed information about Collection query syntax and best practices, please refer to the Polarion SDK documentation.

      Returns:
      The number of persistent objects that match the given SQL query.
      Since:
      3.25.6