-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate trying to instantiate an abstract class
PostPosted: Thu Jan 27, 2005 11:16 pm 
Newbie

Joined: Thu Jan 06, 2005 4:25 pm
Posts: 12
Location: Redwood City, CA
Hi,

I created a simple class hierarchy and mapped it using the "Table per class hierarchy" approach, as described in section 3.6.2 of Hibernate in Action. The base class of my hierarchy is abstract.

I can insert a subclass without any problem. When I query the database, I find a row with the discriminator column set to the proper value.

The problem occurs when I try to do a query that selects multiple objects. When I do this, Hibernate throws up a CGLIB error complaining that it cannot instantiate the base class. I can see no reason why it should be trying to do this, since there are only objects of the subclass type stored.

If I make the base class concrete, Hibernate works fine (and the result set contains only instances of the subclasses, as expected).

In my mapping file, I did not give the base class a discriminator-value, although if I give it one anyway, the behavior is the same.

The stack trace indicates that the attempt to instantiate the abstract class is coming from the constructor of net.sf.hibernate.type.ComponentType.

Let me know what you think, thanks.

Hibernate version:
2.1


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 28, 2005 10:00 pm 
Newbie

Joined: Thu Jan 06, 2005 4:25 pm
Posts: 12
Location: Redwood City, CA
FYI: This happens when you use a composite key without a name or a base class as the key for the abstract class. Refactoring it to use a key object fixed the problem. It would seem that Hibernate somehow needs to instantiate the object to evaluate the composite key, and fails doing so.


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

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.