Ржевский Дмитрий Rzhevskiy Dmitry
понедельник авг 04, 2008
hibernate proxy: instance of not work
There hibernate model classes:

I.e. (a.getAbstractB() instanceOf C || a.getAbstractB() instanceOf D) is false. a.getAbstractB() is proxy for AbstractB.
In order to correct programe necessary
AbstractB b= getImplementation(a.getAbstractB());
и тогда (b instanceOf C || b instanceOf D) будет всегда возвращать true
/**
* unwrap from hibernate proxy.
* @param hibernateProxy proxy with objec subclass
* @return unwrapped object
*/
Object getImplementation(Object hibernateProxy) {
if (hibernateProxy instanceof HibernateProxy) {
HibernateProxy hibernateProxy1 = (HibernateProxy) hibernateProxy;
Object impl = hibernateProxy1.getHibernateLazyInitializer().getImplementation();
return impl;
} else {
return hibernateProxy;
}
}
There described similar problem for equals method
Posted at 06:15PM авг 04, 2008 by Дима in Java | Комментарии[0]
Комментарии:

