-->
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: Failed to uniquely identify an object in many to many table
PostPosted: Tue Aug 18, 2009 6:07 am 
Newbie

Joined: Fri Jul 03, 2009 1:32 am
Posts: 7
Hi

I have two types of user one is an employee and another is a member stored in two tables employee table and a member table respectively.
Id of the employee is mapped
Code:
<id name="empId" type="int">
            <column name="EMP_ID" />
            <generator class="identity" />
        </id>


Id of the member is mapped
Code:
<id name="memberId" type="int">
            <column name="MEMBER_ID" />
            <generator class="identity" />
        </id>

I have another class Qualification which is mapped to the qualification table. Qualification table contain qualification Id and qualification name.

I want to use a unidirectional many to many relational mapping from member to qualification and employee to qualification.
My mapping is
Code:
<set name="qualifications" table="dms_qualification_map">
<key column="MAPPED_ID" />
<many-to-many column="QUAL_ID" class="com.scientia.dms.commons.vo.Qualification"/>
</set>

I am using the same table that is dms_qualification_map for employee and member.
But there is an employee which has the same id of member. I want to uniquely identify the member Id and the employee Id.
That is when retrieving or updating employee the qualification of that employee wants to be retrieved .Now the qualification of the member whose id is same as that of the employee is also retrieved. My idea is to use a new field “Mapped Type” in dms_qualification_map to identify the member and employee uniquely. But I don’t know how it should be mapped.
Please help me.

Thanks in advance.
Scientia


Top
 Profile  
 
 Post subject: Re: Failed to uniquely identify an object in many to many table
PostPosted: Tue Aug 18, 2009 7:51 am 
Beginner
Beginner

Joined: Wed Jun 17, 2009 9:03 pm
Posts: 31
Location: mumbai
Hi
Check if this helps.

Code:
  <class name="Employee" table="emp">
   <id name="id" column="EMP_ID"></id>
   <properties name="qualificationmap" unique="true" update="false">
      <property name="firstproperty" column="x1"/>
      <property name="secondproperty" column="x2"/>
   </properties>
   <set name="qualification" inverse="true">
      <key property-ref="qualificationmap">
         <column name="member_firstproperty"/>
         <column name="member_secondproperty"/>
      </key>
      <many-to-many class="Qualification"/>
   </set>
</class>


or you may need to take composite-id kind of mapping


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.