'How to unproxy a collection of entities in Hibernate?

I have a JPQL query like this

select e from department d join d.employee d where d.id = :departmentId

Unfortunately this returns a ... proxy which is a Proxy-List of ByteBuddyInterceptor?

I tried to unproxy like

(List<Employee>) Hibernate.unproxy(department.getEmployees())

Unfortunately this is not working and I would like to get the List related to the query (instead of having a proxy).

How could I do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source