Subselect fetching is not used for collections if their entity owners are initialized in a batch

Description

An entity class is batch enabled and is using SUBSELECT fetch.

When loading a set of entities and their associations using ID based proxies created with em.getReference(...), rather than using subselect each assocation is loaded with an individual query like the below:

Environment

None

Activity

Show:
Stephen Fikes
April 11, 2016, 8:48 PM

The attachment is not a fix but can be run against Hibernate 5.1.0 or 5.0.9 to create a testcase. The test added will not fail with an error. I enabled logging to see the incorrect queries (i.e. not using subselect).

Gail Badner
May 3, 2016, 6:46 AM

I've pushed test cases and the fix for 5.1 to my fork: https://github.com/gbadner/hibernate-core/tree/HHH-10679-5.1

Gail Badner
June 2, 2016, 8:54 PM

Fixed in master, 5.1, and 5.0 branches.

Assignee

Gail Badner

Reporter

Stephen Fikes

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure