-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: InstantiationException launched with abstract inheritance
PostPosted: Tue Oct 02, 2007 7:28 am 
Newbie

Joined: Tue Oct 02, 2007 6:41 am
Posts: 4
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.