|
|
|
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:
{code:title=IdentifierLoadAccess.java} public interface IdentifierLoadAccess<T> { ... <K extends Serializable> List<T> multiLoad(K... ids); <K extends Serializable> List<T> multiLoad(List<K> ids); } {code}
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:
{code:title=BatchLoadSizingStrategy.java} public interface BatchLoadSizingStrategy { int determineOptimalBatchLoadSize(int numberOfKeyColumns, int numberOfKeys); } {code}
{code:title=Dialect.java} public class Dialect { ... public BatchLoadSizingStrategy getDefaultBatchLoadSizingStrategy() { ... } } {code}
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 optional {{size}} attribute is better?
|
|
|
|