For a Lazy FetchType, query with join returns a concrete object

Description

This example is greatly simplified to what we have in our application.
In this example there are two entities: Event and User. Many events can belong to one user.

In this sample, I am trying to get the Events for a user and I am expecting a proxy object for user with this query:
1. select event from Event event INNER JOIN event.user user where user.id=" + userId

If the above query is run by itself, user proxy object is returned as expected.
But if this query is executed in the same session first where userId is same for both the queries:
2. select user from User user where user.id=" + userId

Then for query 1 above the concrete implementation of user object is loaded since user is already loaded in first level cache.

Is there anyway to know that user object was not actually requested?
In our scenario we have other dependencies on user object causing them to load as well bloating our final object.

Test code attached. Debug line 101 in HQLQueryJoinTest and it will show the concrete user object in event.

Environment

None

Assignee

Unassigned

Reporter

Amish Gandhi

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure