Hi, I'm fairly new to hibernate, but am working on an existing app. I'm using hibernate in an Apache Axis web service.
I have a class A, which is associated with another class location. Location is abstract, sometimes instantiated as a point, sometimes a line. So, my program creates an object of type A and associates it with a point or a line and then does a saveOrUpdate on class A. I can go and check the database and see that all entries are there as expected, with the correct ids and attributes. But when I attempt to retrieve the object A, i get an exception:
- Error performing load command
org.hibernate.InstantiationException: Cannot instantiate abstract class or interface: Location
Now here's the strange part. I have my tester program (test) set up to create an object associated with a point or a line, depending on the command line parameter sent in. So if i say
test point
it creates the object and associates it with a point.
test line
creates the object and associates it with a line.
I am finding that the first time I run it, there are no exceptions. Then I can run "test point" repeatedly and be successful, but when I switch to running "test line", I get the exception mentioned above.
If I restart the web service (all the hibernate code is in the web service), "test line" works again. It's somewhat unpredictable when I will see this exception, but one thing is consistent. If I restart the web service, the next time I run the program, there is no problem.
Each call to add the object to the database and to pull it out are separate sessions and transactions.
Any ideas?
|