I discovered more exactly, where the problem is.
I have code snippet:
Code:
InstrumentHistory ih = svc.query("from InstrumentHistory");
Instrument instrument = ih.getInstrument();
if (instrument instanceof InstrumentOption) {
System.out.println("InstrumentOption");
} else if (instrument instanceof InstrumentFuture) {
System.out.println("InstrumentFuture");
} else {
System.out.println("Unknown type of Instrument:"+instrument.getClass().toString());
}
There are at least two scenarios:
1. When svc.query("from InstrumentHistory") is remote call (SLSBean on JBoss), program prints "InstrumentOption" string.
2. When svc.query("from InstrumentHistory") run on client, so all code run on client, program prints "Unknown type of Instrument: class com.domainmodel.Instrument$$EnhancerByCGLIB$$8dde150f"
So problem is that proxy object does not extend InstrumentOption object or InstrumentFuture object or appropriate object, but extends ancestor InstrumentStatic. When svc.query is remote call, there is serialiazation on server side and deserialization on client side, so it results to right results on client side.
My question: is it bug?
And how to fix this situation?
How to force hibernate after returning object (InstrumentHistory ih) from db to return ( ih.getInstrument() ) appropriate instance of class (InstrumentOption, InstrumentFuture) or proxy that extends from appropriate class.