How can I find out if a certain HibernateProxy is in the first level cache?
The code is roughly
for (HibernateObject obj : objects) {
if (HibernateUtils.isHibernateProxyInCache(
obj.getExpensiveLazyObject())
) {
display(obj.getExpensiveLazyObject());
} else {
display("click here to see expensive lazy object");
}
}
the code I need is HibernateUtils.isHibernateProxyInCache, but I don’t know how to implement it.
I think you’re looking for
Hibernate.isPropertyInitialized.Calling
HibernateUtils.isHibernateProxyInCache(obj.getExpensiveLazyObject())would initialize the proxy to the expensive lazy object, so your method would always return true.