-->
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: difficulty in mapping a map for a class
PostPosted: Fri May 22, 2009 5:18 am 
Regular
Regular

Joined: Fri May 22, 2009 4:50 am
Posts: 59
Hi,
I am just a beginner with hibernate. Kindly help me with following problem.

I have a class A having class B as an attribute. And class B is having just a map as an attribute in it.
I want that whenever a record is inserted/deleted in table for A, it should insert/delete corresponding record from table for its map.
It would have been easy to map it if class A directly contained a map in it. But what will be the optimised way to map it in this case?

Though I have achieved it by following hibernate mapping, I have to use an intemediate table for B which can be avoided. Kindly let me know if any suggestion.

<class name="A" table="TBL_A">
<id name="id" column="A_ID" type="java.lang.Integer">
<generator class="sequence">
<param name="sequence">A_sequence</param>
</generator>
</id>
<many-to-one name="positionMap"
class="B"
column="ID"
cascade="all"
unique="true"/>
<class/>
<class name="B" table="TBL_B">
<id name="id" column="ID">
<generator class="sequence">
<param name="sequence">B_sequence</param>
</generator>
</id>
<map name="CMap" table="TBL_C" cascade="all">
<key column="ID" />
<index column="C_KEY"/>
<element column="C_VALUE"/>
</map>
</class>


Thanks in adavnce.


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.