Skip to content

Commit

Permalink
add Query.getResultCount()
Browse files Browse the repository at this point in the history
see issue jakartaee#622

Signed-off-by: Gavin King <[email protected]>
  • Loading branch information
gavinking committed Sep 20, 2024
1 parent 24bf062 commit 6807660
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/src/main/java/jakarta/persistence/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

// Contributors:
// Gavin King - 4.0
// Gavin King - 3.2
// Lukas Jungmann - 2.2
// Linda DeMichiel - 2.1
Expand Down Expand Up @@ -61,6 +62,24 @@ public interface Query {
@SuppressWarnings({"rawtypes"})
List getResultList();

/**
* Determine the size of the query result list that would be
* returned by calling {@link #getResultList()} with no
* {@linkplain #getFirstResult() offset} or
* {@linkplain #getMaxResults() limit} applied to the query.
* @return the size of the list that would be returned
* @throws IllegalStateException if called for a Jakarta
* Persistence query language UPDATE or DELETE statement
* @throws QueryTimeoutException if the query execution exceeds
* the query timeout value set and only the statement is
* rolled back
* @throws PersistenceException if the query execution exceeds
* the query timeout value set and the transaction
* is rolled back
* @since 4.0
*/
long getResultCount();

/**
* Execute a SELECT query and return the query results as an untyped
* {@link java.util.stream.Stream}.
Expand Down

0 comments on commit 6807660

Please sign in to comment.