-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping table with two colums, which are composite PK key.
PostPosted: Wed Feb 28, 2007 3:28 am 
Newbie

Joined: Wed Feb 28, 2007 3:04 am
Posts: 2
Hi all.

I have 3 simple tables: User_Profile, Group_Profile, Group_Membership.

Table User_Profile
--> [PK] User_ID

Table Group_Profile
--> [PK] Group_ID

Table Group_Membership
--> [PK] Group_ID
--> [PK] Group_ID

I have mapping for the table Group_Membership:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="GroupMembership, businesslayer" table="group_membership" lazy="false">
      <composite-id name="Id" class="GroupMembershipKey, businesslayer">
         <key-property name="User" column="user_uid" />
         <key-property name="Group" column="group_id" />
      </composite-id>
   </class>
</hibernate-mapping>


All i want is to have in class GroupMembership two public properties: Group and User, which return corresponging mapping objects. But when i had tried uncomment sections <many-to-one>, i got mapping error.
Also, i what to use find criteria for getting all groups in which user register.
Please, help me to solve this problem.


Last edited by timka on Sat Feb 02, 2008 1:04 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 28, 2007 3:50 am 
Newbie

Joined: Wed Feb 28, 2007 3:04 am
Posts: 2
I found solution, may be it will helps somebody.

I have wrong mapping for the <composite-id> section. The correct is
Code:
      <composite-id name="Id" class="GroupMembershipKey, businesslayer">
         <key-many-to-one name="User" column="user_uid" />
         <key-many-to-one name="Group" column="group_id" />
      </composite-id>


And then i can uncomment <many-to-one> sections :).

Thanks all, topic close.


Last edited by timka on Sat Feb 02, 2008 1:04 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 5:41 am 
Newbie

Joined: Sat Mar 17, 2007 11:58 am
Posts: 2
Location: Brussels
Hi,

I have the same problem but your solution don't work for me.. :-s

Can you post your xml and code please?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.