Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor clarification to what is returned by getResultList() #538

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions api/src/main/java/jakarta/persistence/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public interface Query {
/**
* Execute a SELECT query and return the query results as an untyped
* {@link List}.
* @return a list of the results
* @return a list of the results, or an empty list if there are
* no results
* @throws IllegalStateException if called for a Jakarta
* Persistence query language UPDATE or DELETE statement
* @throws QueryTimeoutException if the query execution exceeds
Expand Down Expand Up @@ -68,7 +69,8 @@ public interface Query {
* however persistence provider may choose to override this method
* to provide additional capabilities.
*
* @return a stream of the results
* @return a stream of the results, or an empty stream if there
* are no results
* @throws IllegalStateException if called for a Jakarta
* Persistence query language UPDATE or DELETE statement
* @throws QueryTimeoutException if the query execution exceeds
Expand Down
21 changes: 12 additions & 9 deletions api/src/main/java/jakarta/persistence/TypedQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ public interface TypedQuery<X> extends Query {

/**
* Execute a SELECT query and return the query results as a typed
* {@link List}.
* @return a list of the results
* {@link List List&lt;X&gt;}.
* @return a list of the results, each of type {@link X}, or an
* empty list if there are no results
* @throws IllegalStateException if called for a Jakarta
* Persistence query language UPDATE or DELETE statement
* @throws QueryTimeoutException if the query execution exceeds
Expand All @@ -60,13 +61,14 @@ public interface TypedQuery<X> extends Query {

/**
* Execute a SELECT query and return the query result as a typed
* {@link java.util.stream.Stream}.
* {@link java.util.stream.Stream Stream&lt;X&gt;}.
*
* <p>By default, this method delegates to {@code getResultList().stream()},
* however, persistence provider may choose to override this method
* to provide additional capabilities.
* <p>By default, this method delegates to {@link List#stream()
* getResultList().stream()}, however, persistence provider may
* choose to override this method to provide additional capabilities.
*
* @return a stream of the results
* @return a stream of the results, each of type {@link X}, or an
* empty stream if there are no results
* @throws IllegalStateException if called for a Jakarta
* Persistence query language UPDATE or DELETE statement
* @throws QueryTimeoutException if the query execution exceeds
Expand All @@ -93,7 +95,7 @@ default Stream<X> getResultStream() {

/**
* Execute a SELECT query that returns a single result.
* @return the result
* @return the result, of type {@link X}
* @throws NoResultException if there is no result
* @throws NonUniqueResultException if more than one result
* @throws IllegalStateException if called for a Jakarta
Expand All @@ -117,7 +119,8 @@ default Stream<X> getResultStream() {

/**
* Execute a SELECT query that returns a single untyped result.
* @return the result, or null if there is no result
* @return the result, of type {@link X}, or null if there is no
* result
* @throws NonUniqueResultException if more than one result
* @throws IllegalStateException if called for a Jakarta
* Persistence query language UPDATE or DELETE statement
Expand Down