When retrieving a {{LAZY}} association property and attempting to downcast the returned entity, a {{ClassCastException}} is raised due to the use of the {{javassist}} proxy (even if the proxy is initialized). The proxy must be "unwrapped" to downcast using something like the below.
{code} (( org.hibernate.proxy.HibernateProxy) entity).getHibernateLazyInitializer().getImplementation(); {code}
It would be useful to provide something like an {{org.hibernate.Hibernate.unproxy(Object proxy)}} method rather than requiring users to access the proxy interface as above. |
|