Lazy fetch type doesn't work for identical objects

Description

There is User Entity:

There is Permission Entity:

I use this code to fetch User Entity:

Look at the comment in code above:

It means, that without any calls to targetUser, hibernate fetches it. That's really strange. This behavior really slows down performance of my application.

My assumption: Hibernate just can't proxy two similar objects in one entity (i mean, user and targetUser have the same class, hibernate cannot proxy both objects and thats why it fetches targetUser immediately)

How to solve this problem? Any suggestions?

Environment

None

Assignee

Unassigned

Reporter

Xset

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Priority

Major
Configure