I am debugging a weird occassion where the SUBSELECT fetch strategy doesn't seem to work. The use case: from a list of A, get all lists of B. Instead of running the query to get B once, it runs the query
once for every A. The ran queries are exactly the same, the where-in subselect gets properly injected and all duplicates have the same parameter values. I have been stepping through the SubselectOneToManyLoader code but it is not trivial where exactly this goes wrong. For instance, the "keys" array is filled properly with all 1254 ids of the fetched entities. I have been suspicious about whether this could be a bug in Hibernate, but so far I couldn't reproduce this with a "clean-slate". I am therefore looking for input desperately ;)
A few thoughts:
* Even though Hibernate should support Streams, could it be that a Stream of the below form breaks the SUBSELECT fetching?
List of A's -> stream -> map list of B's -> flat map stream -> consume
* Could it be that SUBSELECT fetching does not work properly on enhanced entities? (hibernate-enhance-maven-plugin)
* Could it be that a custom OneToMany persister breaks the SUBSELECT fetch strategy? (I am using the
https://github.com/Blazebit/blaze-persi ... ister.java )
* Could it be that SUBSELECT fetching does not work with SortNatural?
* Could it be that SUBSELECT fetching does not work properly with inheritance trees or multiple collection fields that use SUBSELECT fetching?
Any input will be much appreciated!
Jan-Willem