Jira issue originally created by user mpdude:
Available documentation is a bit thin regarding the "WITH" clause on JOIN expressions. Only a single example is provided in
WITH seems to allow to only "partially" load a collection, so the collection in memory does not fully represent the associations available in the database.
The resulting collection is marked as "initialized" and it seems there is no way to tell later on whether/how (with which expression) the collection has been initialized.
When using the collection filtering API, the "initialized" flag on the collection will lead to in-memory processing. If a collection has been loaded WITH a restricting clause and another filter is applied later, results may not be what one might expect.
I assume this is by design (no idea how the collection could be "partially" loaded and behave correctly under all conditions), so filing it as a documentation issue.
Comment created by mpdude:
An additional observation:
If you eager-load a collection using WITH, for the resulting entities that collection is marked as initialized as described above.
Should you happen to come across the same entity during hydration in another (later) context where you explicitly eager load the same association without the WITH restriction (or with another one), the collection on that (existing) entity won't be re-initialized and still contains the associated objects found during the first query.