Back Forum Reply New

ClassCastException....

Hi All

I am using spring and hibernate in my project.

This is the Object hierarchy I have and am using table per class hierarchy model.

Class Abstract Base;
Class Abstract TempDiscontinuation extends Base;
Class TempDiscontinuationA extends TempDiscontinuation;
Class TempDiscontinuationB extends TempDiscontinuation;

class Enroll {   private TempDiscontinuation tempDiscontinuation ;
}

In my controller I am creating the TempDiscontinuationA and setting it in Enroll and saving it. When I say

TempDiscontinuation tempDiscontinuation = enroll.getTempDiscontinuation();
if(tempDiscontinuation instanceof TempDiscontinuationA) {   ........   ........
}
the above IF condition is failing. When I print the tempDiscontinuation it is printing TempDiscontinuationA, but when I check with instanceof or type cast with TempDiscontinuationA it is failing.

What could be the reason for this. Am I missing somthing

Thanks in advance.
--smith

Would help if you attach more of your code and the hbm files. Putting them around the CODE tag also helps

Class loading problem, proxy, etc. There can be many reason for this.

Joerg
¥
Back Forum Reply New