Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jpa-dev] [DISCUSS] Streaming queries?
  • From: Oliver Drotbohm <odrotbohm@xxxxxxxxxx>
  • Date: Mon, 8 Mar 2021 15:50:25 +0000
  • Accept-language: de-DE, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HEGVX2cl4Rvd1gbcKG9lVP2xrYdOs7FeYpzctlI71Go=; b=oXGiwzRQSJCh6AccMPjTZGFrp2E+PWZvFwJg40jY31Qe9jPGmuDQsaWjVYT51OZLZmPYYQqKHZZNNjr7Stq8NJkC5mX40XWWrBOA9IICcpaYBc1y2KhU8+MnWugrAMRZKRrESdSt/rWmnGFzf4onjkT13Djpof4A8T60OgurTLA9lmjOfzSlyEiHq69/mDXIIcuFip15Ze/giolEIdbe4yv9xRa/lH6mcayf3IetirTsbdoD8V0odsKtPqCi+cFvkC1wjIEqFdEYA1TewApWp9ICJ19SmqcuI3KV4DObXWpoo3GWmCfRyuwDlQnlOUw6s+Brz1QNlwJiOFGzW1bTZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LmB7hhKsuLcRSFg21NyGDWFgwo9gQQAEQf0o3kA7BfV92Qh0YENtaKLjVbbs14nvnjdBNI8IvCxWeGsZv1axcgappaAIQcwYfu/bHovZB4o8H7KaHn89HTh7JQQrQzlW22yFCv6/w1CedPvD49xrXPaEPmiiLmMWE8wFreEdvHSbc1RcuMyL380LC3BelrdRVFLCpvIYqd5aTX5Es52ODt/WdktXNSxOW89+KFdjvNL42zuR+hFSW+Dv7w6KRQIl7KKKUoVXdcUF9yCdyjuh/XiGKJ4UNbtW+IsYK3UXYviJie7UtyEwLstBNuEutwIa8mylV/mP9k6wcKF832uwuw==
  • Delivered-to: jpa-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/jpa-dev/>
  • List-help: <mailto:jpa-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/jpa-dev>, <mailto:jpa-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/jpa-dev>, <mailto:jpa-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHXFC9D60acby1Cjkm82swFgfXLeqp6PSIA
  • Thread-topic: [jpa-dev] [DISCUSS] Streaming queries?

I don't quite get what the actual point of the suggested library is: that the Criteria API is hard to use? Well, that's not news. And has been worked around in stuff like Querydsl.

I think introducing an alternative to the Criteria API in the spec itself is adding quite a bit of complexity. Not sure whether that's a good idea.

Other than that, I found the focus on streams in the name of the library quite weird as all that's done to the Stream is a `toList()` effectively. Returning streams from JPA queries is a strange beast in the first place as they're essentially "live" objects that still need a connection to properly be traversable. Which makes them easy to use incorrectly. I.e. if you hand a `Stream` out of a transactional method, it's not actually usable as the underlying `EntityManager` has been closed.

A bit of feedback on the Spring Data JPA samples in the blog post:

- pretty much everything laid out in the first code samples is available in Spring Data JPA repositories OOTB. Declare a `Stream<User> findAllBy(Pageable pageable)`. Done. See [0] for details.
- the Spring MVC example looks artificially convoluted as you can just declare a `Pageable` as MVC handler method parameter and then call the aforementioned method. See [1] for details.

Cheers,
Ollie

[0] https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-streaming
[1] https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#core.web.basic.paging-and-sorting

> Am 08.03.2021 um 16:25 schrieb Ivar Grimstad <ivar.grimstad@xxxxxxxxxxxxxxxxxxxxxx>:
> 
> Hi,
> 
> Do you think it would be worthwhile pursuing something like this in a future version of the specification?
> 
> https://blogs.oracle.com/javamagazine/jpastreamer-expressing-hibernatejpa-queries-with-java-streams
> 
> Ivar
> 
> --
> Ivar Grimstad
> Jakarta EE Developer Advocate | Eclipse Foundation
> Eclipse Foundation - Community. Code. Collaboration.
> _______________________________________________
> jpa-dev mailing list
> jpa-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jpa-dev

Attachment: signature.asc
Description: Message signed with OpenPGP


Back to the top