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

Fetch size optimization can be applied by `ListingConfig.ORG_HIBERNAT… #15

Merged
merged 2 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

* Visual table summary? Want to know what's the most of something? No problem! You can acquire terms and statistics by just throwing attribute names into filter! Have a look at *Visual Table Summary* in this [UX Collective article](https://uxdesign.cc/design-better-data-tables-4ecc99d23356).
* TO FUCKING DO!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete me...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

der pull reqeust geht ja nur in den 1.6.0-SNAPSHOT branch, da fehlt noch doku...

* Fetch size optimization can be applied by `ListingConfig.ORG_HIBERNATE_FETCHSIZE`, witch will add `typedQuery.setHint("org.hibernate.fetchSize", ListingConfig.ORG_HIBERNATE_FETCHSIZE);` to the query if set.

<a name="1.5.1"></a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ public class ListingConfig {
public static String TIME_ZONE = "UTC";
public static ZoneId ZONE_ID = ZoneId.of(TIME_ZONE);

/**
* <code>org.hibernate.fetchSize</code> tells the JDBC driver how many rows to return in one chunk, for large queries.<br>
* If this is set to <code>0</code> (default) it will not be applied. <br>
* <br>
* <i><code>org.hibernate.fetchSize</code> will do nothing if your driver does not support it!</i> <br>
* <br>
* Say you want 1000 rows. If you set the fetch size to 100, the database will return 100, then another 100 when you want more, and so on. <br>
* <br>
* You can also set this globally by adding <code>&lt;property name="hibernate.jdbc.fetch_size" value="100"/&gt; </code> to your options in
* <code>persitence.xml</code>
*/
public static int ORG_HIBERNATE_FETCHSIZE = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich glaub ich würde hier das Ding einfach nur FETCHSIZE nennen, den unter umständen wechselt die Implementierung drunter. Zum Beispiel via Eclipselink...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hatte ich auch gedacht, aber wieder vergessen


/**
* Name of the (optional) listing property file
*/
Expand Down Expand Up @@ -231,6 +244,7 @@ private static void loadProperties() {
URI_DECODE = loadProperty(URI_DECODE, "coodoo.listing.uri.decode");
URI_CHARACTER_ENCODING = loadProperty(URI_CHARACTER_ENCODING, "coodoo.listing.uricharacterencoding");

ORG_HIBERNATE_FETCHSIZE = loadProperty(ORG_HIBERNATE_FETCHSIZE, "coodoo.listing.org.hibernate.fetchSize");
}
} catch (IOException e) {
log.info("Couldn't read {}!", listingPropertiesFilename, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ public List<T> list(Integer startPosition, Integer limit) {
if (limit != null && limit > 0) {
typedQuery.setMaxResults(limit);
}
if (ListingConfig.ORG_HIBERNATE_FETCHSIZE != 0) {
typedQuery.setHint("org.hibernate.fetchSize", ListingConfig.ORG_HIBERNATE_FETCHSIZE);
}
return typedQuery.getResultList();
}

Expand Down