Hello,
I have following entities:
Code:
class User {
Integer id;
Set<Role> roles;
}
class Role {
Integer id;
}
In my application I have logic layer and persistent layer.
Logic is executed outside of Hibernate session, so lazy loading cannot be used.
When business logic ask entities from persistent layer, it defines (in parameters) which associations must be initialized.
In one situation my business logic needs to load users with roles. This is OK. Persistent layer can load roles by using Hibernate join fetch.
In other situation my business logic needs to load users WITHOUT roles, and this is my problem. Hibernate sets lazy loading proxy collection as roles, I would like to get NULL value instead. In this situation role association must be kind of disabled.
Is this possible to do with Hibernate?
Hibernate gurus please help me.