Hi,
I think I've isolated the problem and I know when it happens but I'm not sure how to solve it.
I have an inheritance hierarchy and imagine that A class is an abstract superclass and B is a concrete subclass (in fact I have more concrete classes but it's not specially important). The Java POJOs are defined like this, so A is abstract and B is not and in the A.hbm.xml the abstract attribute is set.
In the application code I have a one-to-many association from another class, let's say Z to A. In some moment I want to remove all the A instances associated to Z, so I have a similar code to this in Z:
Code:
Z z = new ...
for(A a : z.getAs())
{
session.delete(a);
}
Normally this code works well but I have a problem. The actual database is not only handled by this application and even when for the application has no sense to have tuples in the A table if there is not a corresponding one in B table for some external applications it can have sense. In this sitution the InstantiationException is launched.
Any idea how to solve this? In an ideal situation this inconsistent state shouldn't happen but till this will be solved the hibernate application should be able to handle it. I would like to have all the tuples removed in this case (even if there is no concrete instance B) and to avoid the launch of the exception. Any idea?
Thanks,
Iván