Hibernate version: 2.1.7c
Hi there,
I have a class Animal and two subclasses Cat and Dog:
Animal
-->Cat
-->Dog
using joined subclasses. In the database, there is one instance of Cat with id 1 and one instance of Dog with id 2.
When I execute:
Cat cat = (Cat) session.load(Cat.class, 1);
Dog dog = (Dog) session.load(Dog.class, 2);
everything is fine. However, when I execute:
Cat cat = (Cat) session.load(Cat.class, 1);
Dog dog = (Dog) session.load(Dog.class, 2);
Dog dog = (Dog) session.load(Dog.class, 1);
I get a ClassCastException instead of a ObjectNotFoundException? Also: only the first two lines result in a database access. Hibernate seems to ignore the fact that I'm trying to load Dog with id 1 (which does not exist) and retrieves the previously loaded Cat with id 1 from the cache, thus resulting in a class cast exception? The same thing happens with get()! What am I missing?
Thanks,
Jonas
|