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.
|