Hi all,
I got hit with the infamous LazyInitializationException. The problem is that we have one very common method in our code base:
public Object findById(Class entityClass, Long id) {
Object result =
getHibernateTemplate().get(entityClass, id);
try {
getSession().evict(result);
} catch (HibernateException e) {
throw convertHibernateAccessException(e);
}
return result;
}
The problem is with the evict() call. We have an OpenSessionInViewFilter. I tried solving the problem via only XML, as referenced here:
http://www.jroller.com/page/kbaum/20040708
Unfortunately I was not successful.
Using session.lock(object, LockMode.NONE); solves the problem, but is a bit intrusive on the code base.
Question: Given the evict() call, is it possible to solve the problem with only the xml configuration of Spring? Would hibernateInterceptor help here?
iksrazal