Stream<X> getResultStream()
Execute a SELECT query and return the query result as a typed Stream<X>.
By default, this method delegates to List, however, persistence provider may choose to override this method to provide additional capabilities.
- 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
- QueryTimeoutException - if the query execution exceeds the query timeout value set and only the statement is rolled back
- TransactionRequiredException - if a lock mode other than {@code NONE} has been set and there is no transaction or the persistence context has not been joined to the transaction
- PessimisticLockException - if pessimistic locking fails and the transaction is rolled back
- LockTimeoutException - if pessimistic locking fails and only the statement is rolled back
- PersistenceException - if the query execution exceeds the query timeout value set and the transaction is rolled back
- QueryTimeoutException - if the query execution exceeds the query timeout value set and only the statement is rolled back
- See Also:
- Stream
- getResultList()
- Since:
- JPA 2.2