• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate mapping

 
chiranjeevi gunturu
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends.
I have a problem in hibernate mapping between two tables.

the below is the mapping file:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Group" table="group_category">
<id name="categoryID" column="group_category_id" type="java.lang.Long">
<generator class="assigned"/>
</id>
<property name="shortDescription" column="group_category_short_description"/>
<property name="longDescription" column="group_category_long_description"/>
<list name="groupPermission" table="group_permission" cascade="all">
<key column="group_category_id" update="true"/>
<index column="item_code"/>
<one-to-many class="GroupPermission"/>
</list>
</class>
<class name="GroupPermission" table="group_permission">
<composite-id>
<key-property name="categoryID" column="group_category_id" type="java.lang.Long"/>
<key-property name="itemcode" column="item_code" type="java.lang.String"/>
</composite-id>
<property name="shortDescription" column="group_permission_short_description"/>

</class>
</hibernate-mapping>

i have two tables. 1) Group
2) GroupPermission

GroupPermission table has a composite key which consists of:
1)Group id that is generated from the 1st table.
2)itemcode which is a string.

as you see in the mapping file i mentioned itemcode as the index column.
i think the index column should be integer or some numeric value.
so what should i do to solve this problem.

please help me in solving this problem. Thank you all
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you still have to have the GroupPermission mapping have a composite id, then yiu have to map the Group to the GroupPermission using both columns and you cann't use



It needs both columns from the compositeid.

Or if group_category_id single handidly uniquely identifies a group category record, then do not use composite id.

Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OH, and please use the CODE tags to post code or xml, os that your indentation remains. Without it it makes it really difficult to read your xml.

Thanks

The Code button under the Add Reply Button will add the CODE tags

Mark
 
chiranjeevi gunturu
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic