-->
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: Persisting a Map with interface as value
PostPosted: Mon Feb 02, 2004 4:50 am 
Newbie

Joined: Tue Jan 06, 2004 5:52 am
Posts: 17
Location: Belgium
Hi,

I have a class containing a Map. This Map has a String as key, the value is some interface, currently implemented by 3 concrete classes. How can I do the hibernate mapping in this case? If I try to map the interface, I get a NullpointerException (probably because there is no primairy key definined).

So I want to do this for the class that contains the Map:

Code:
<map name="myMap">
   <key column="id"/>
   <index type="string"/>
   <element  type="myInterface"/>
</map>


but then I get an error ofcourse that myInterface is not a persistent class.

kind regards,

Wim


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 6:19 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
I did this way
Code:
<joined-subclass name="ClassAImpl" table="classa" proxy="ClassA">
   <key column="genericParam" />

   <joined-subclass name="ClassBImpl" table="classb" proxy="ClassB">
      <key column="genericParam" />
   </joined-subclass>                                

   <joined-subclass name="ClassCImpl"
                table="classc"
                proxy="ClassC">
      <key column="genericParam" />
      <map name="condizioni" inverse="true"  lazy="true" cascade="all">
         <key column="base"/>
         <index column="nomeCondizione" type="string"/>
         <one-to-many class="ClassAImpl" />               
      </map>

   </joined-subclass>                                

   <joined-subclass name="ClassDImpl" table="classd" proxy="ClassD">
      <key column="genericParam" />
   </joined-subclass>                                

   <joined-subclass name="ClassEImpl" table="classe" proxy="ClassE">
      <key column="genericParam" />
   </joined-subclass>                                

</joined-subclass>


Hope this can help.
Ciao.


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.