I am using spring + hibernate in my project; I have two classes Reminder
and Client
in class reminder i have added a relationship of many to one for client and it is by default eagerly loaded. I want this Object graph most of the scenarios in my project so i have set fetch type eager for client in reminder class
Class Reminder {
@ManyToOne
Client client;
}
but for one or two scenarios i want to keep initialization of this object client lazy;
so i have added in method for fetching reminders is like below
Criteria c = session.createCriteria();
c.setFetchMode("client", FetchMode.SELECT);
hibernateTemplate.findByCriteria(criteria);
it is not working; it still loads client objects with reminder
while reverse (from lazy to eager) is working fine