Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

hibernate mapping

 
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
 
ranger
Posts: 17346
11
Mac IntelliJ IDE 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
Posts: 17346
11
Mac IntelliJ IDE 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.
    Bookmark Topic Watch Topic
  • New Topic