Develop API for load-by-multiple-ids
Description
follows up on
is duplicated by
Activity
Steve Ebersole November 9, 2015 at 10:23 PM
At this point, lets move the "collection initialization" discussion to
Steve Ebersole November 6, 2015 at 3:48 PM
In regards to your idea of a "batch initialize collections" feature, can you propose an API for what that might look like?
Are these all collections of the same role? Or a mix-bag?
Do we need to allow configuring how this happens like we are proposing with this "entity multi-load" API? Or is it a more simple "here are a number of collections, please just get them initialized"?
We could follow the approach being taken for "entity multi-load":
CollectionInitializerAccess.java
Unfortunately Map and the others not sharing a common interface makes that API a bit awkward in terms of the arguments. Possibly we could say...
CollectionInitializerAccess.java
WDYT? Or do you have an alternative suggestion?
Steve Ebersole November 6, 2015 at 3:35 PM
I added a new PR illustrating another possible approach: https://github.com/hibernate/hibernate-orm/pull/1137
Steve Ebersole November 5, 2015 at 9:49 PM
lambdas of course would mean Java 8, so there's that. I'm looking forward to baselining on Java 8 for other reasons, so we can start to discuss that moving forward. I had hoped to keep 5.x Java 6 compatible, but am open to discussing it.
Steve Ebersole November 5, 2015 at 9:47 PM
I just pushed https://github.com/hibernate/hibernate-orm/pull/1136 for everyone to see (and discuss) the design and initial impl
Hibernate does not have any explicit handling for excessive expressions in an in-list expression in HQL. There are many reported issues that come out of this (see linked issues, and their linked issues). In my opinion, the vast majority of these come from (imo) invalid queries.
However, there is one use case where this complaint comes up that is valid imo; specifically the case of wanting to load multiple entities by id at one shot. We should develop an API for allowing this. Something along the lines of:
IdentifierLoadAccess.java
In support of that (and batch fetch loading too), consider adding a "optimal batch size" determination strategy. Today we rely on the user explicitly telling us the batch size to use. Would be nice to have a determination for that as a default, especially a Dialect-specific determination:
BatchLoadSizingStrategy.java
Dialect.java
Also allow users to specify a custom BatchLoadSizingStrategy; the Dialect one is just the default.
Would also be nice to allow batch fetch loading to leverage this strategy-based determination. One option would be to simply make the
size
on@BatchSize
optional. That unfortunately leaves@BatchSize
poorly named overall. Maybe deprecating@BatchSize
in favor of a new@BatchLoadable
with an optionalsize
attribute is better?