-->
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: Map two columns with the Single class
PostPosted: Thu Sep 24, 2009 4:50 am 
Newbie

Joined: Thu Sep 24, 2009 3:13 am
Posts: 2
Hi,

I want to map two columns (createdBy and modifiedBy - both the columns are foreign keys in PersonalDetails table and referenced with "userID" in 'User' table ) with the class "User" (PK: userID).

Foreign Keys:

CONSTRAINT FOREIGN KEY (`CreatedBy`) REFERENCES `User` (`UserID`),
CONSTRAINT FOREIGN KEY (`ModifiedBy`) REFERENCES `User` (`UserID`),

I have written a many-to-one relation to map both the fields.

table: PersonalDetails

<many-to-one name="modifiedBy" class="com.User">
<column name="ModifiedBy" not-null="true" />
</many-to-one>

<many-to-one name="createdBy" class="com.User">
<column name="CreatedBy" not-null="true" />
</many-to-one>

while mapping like the above, am getting the following error

"An association from the table PersonalDetails refers to an unmapped class com.User"

Could you plz give me the solution to resolve this or do I need to change the hibernate mapping code?


Top
 Profile  
 
 Post subject: Re: Map two columns with the Single class
PostPosted: Thu Sep 24, 2009 8:35 am 
Newbie

Joined: Thu Sep 17, 2009 9:31 am
Posts: 10
Make sure you have both classes mapped.

The hibernate docs recommend using one mapping file per class.

In your case, they would be User.hbm.xml, and PersonalDetails.hbm.xml. Also, make sure they are both added to your configuration, so that the application is able to find them.


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.