speedment / jpa-streamer

JPAstreamer is a lightweight library for expressing JPA queries as Java Streams
GNU Lesser General Public License v2.1
339 stars 35 forks source link

Implements @QueryHints or similar #320

Closed manuelserradev closed 1 year ago

manuelserradev commented 1 year ago

To process large amount of data is sometime needed to provide additional configuration for the underlying JDBC driver, eg. to disable full resultsets cache in ram.

This is particularly useful to enable cursor "streaming" on the dbms side: eg. getting-results-based-on-a-cursor.

Usually this is implemented with @QueryHints annotations in spring or .withHint methods on Panache repositories.

    return findAll()
        .withHint(QueryHints.HINT_FETCH_SIZE, 50)
        .withHint(QueryHints.HINT_READONLY, true)
        .stream()
        .map(this::detach);

I strongly think that this feature greatly fits JPAStreamer as it permits streaming at all layers involved.

julgus commented 1 year ago

Thank you for the suggestion! I will take a closer look.

manuelserradev commented 1 year ago

I think I can try drafting a PR if you find it valuable. I was thinking of expanding StreamConfiguration capabilities...

julgus commented 1 year ago

Yes, that would definitely be valuable. Expanding the StreamConfiguration sounds like a good way to go!

julgus commented 1 year ago

@minborg could you also share your view on this?

julgus commented 1 year ago

Sorry for not paying attention to your draft sooner! Completely missed it. I've left a comment regarding missing JavaDocs, other than that it looks great. Thank you for helping out!

Before I can merge your changes I need you to sign a Contributor Licence Agreement. We have described why and how that is done here: https://github.com/speedment/jpa-streamer/blob/master/CONTRIBUTING.md.

julgus commented 1 year ago

I just merged your changes into the development branch. I cannot say for sure when we will make the next official release but most likely within the next month. Your name is now also on the list of contributors.

Thanks again for your valuable input and contribution!

julgus commented 1 year ago

Almost forgot! We need to document this feature in our docs to make sure anyone who searches for "query hints" can find it. I made an attempt to write something up. Do you mind checking my commit to see if it needs any changes or additions in your opinion?

manuelserradev commented 1 year ago

LGTM!