-->
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: Mapping class with collection of interface types
PostPosted: Thu Mar 02, 2006 12:57 pm 
Newbie

Joined: Thu Feb 02, 2006 5:33 am
Posts: 1
Hi,

I am new to Hibernate, and have hit on the following problem :

I have a class has a composite element of a HashMap, which contains key-value pairs of : String - MyInterface.

Different instances of the class may have different implementations of MyInterface as the value in the Map.

The error traces below occur when I try to retrieve the instance (it persists without any problem), as I assume Hibernate is trying to instantiate the Interface.

Other than creating seperate identical classes and seperate mapping files, can anyone suggest how best to implement this?

Any advice would be greatly appreciated ...



Hibernate version:3.0.5

Mapping documents:
<hibernate-mapping package="somebusiness">

<class name="SomeInstance" table="gen_inst">
<id name="id" column="uid" type="long">
<generator class="identity"/>
</id>
<property name="instanceName" type="string" />
<map name="configObjects" table="portlet_instance" cascade="all">
<key column="map_instance_id"/>
<index column="some_name" type="string"/>
<many-to-many column="config_bean" class="MyInterface"/>
</map>
</class>

<class name="MyInterface" table="the_interface">
<id name="id" column="uid" type="long">
<generator class="identity"/>
</id>
<property name="someAttribute" type="string" length="20"/>
</class>

</hibernate-mapping>




Full stack trace of any exception that occurs:
INFO: Error performing load command
org.hibernate.InstantiationException: Cannot instantiate abstract class or interface: somebusiness.MyInterface
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:56)


Name and version of the database you are using: IBM UDB 7


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 4:14 pm 
Regular
Regular

Joined: Wed Feb 08, 2006 3:59 pm
Posts: 75
Your mapping file needs to tell Hibernate which are the concrete classes to instanciate. Take a look at inheritance mapping :

http://www.hibernate.org/hib_docs/v3/reference/en/html/inheritance.html


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.