|
This is working as designed and is therefore impossible to be a "bug". You are just misunderstanding how entity batch loading works and, more specifically, when it comes into play.
You described what happens in loading a collection from the second level cache very well. The collection cache stores the basic element values; in the case of entity elements that means the associated entity FK value. Each entity is then loaded one by one. The design here is meant to cater for the associate entity being cached as you point out.
Entity batch loading works on entity proxies associated with the Session. As we initialize one proxy, we will also initialize X number of other proxies for the same entity type.
In this "load collection from second level cache" use case there is no entity proxies in play.
|