I have a ManyToOne Mapping (fetch EAGER), but the class is enhanced using CGLIB.
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="animalId)
public Animal getAnimal() {
...
}
the Animal instance becomes Animal$$EnhancerByCGLIB$$9877ae. As a result, I can not use instanceof or cast, for example,
Animal a = getAnimal();
if (a instanceof Dog) {
....
}
I know it is a Dog, but I can not cast it, like
Dog d = (Dog)a;
How to prevent Animal class from being enhanced? I need to use Animal instead of Animal$$EnhancedByCGLIB$$...
Thanks for help!
Dave
|