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: Simple mapping question
PostPosted: Mon Jun 30, 2008 10:30 am 
Newbie

Joined: Wed May 07, 2008 4:39 am
Posts: 3
Hi,

I have to map a database I didn't design, so I can't change anything of the following:

[Employee] Table:

Employee_ID (PK)
Employee_Name
Employee_Num

[Employee] Object:

Employee.ID
Employee.Name
Employee.Num
Employee.Department

[Department] Table:

Employee_Num (PK)
Department_Name

[Department] Object:

Department.Employee
Department.Name


I don't know how to define the mapping between the Employee and Department table. I considered component and one-to-one, but couldn't make it work.

Any idea?

Thanks a lot in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 01, 2008 10:16 am 
Newbie

Joined: Mon Jun 30, 2008 12:56 pm
Posts: 6
Recommendation:

1.) Use a local database to mirror the production environment.
2.) Create the same table with same columns (type/column name)

Once it works, just change the connection string to your production and it should work without any problem!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 02, 2008 2:43 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
A component uses columns from the same table, so that's not possible here. You can use a many-to-one association here (at the end of 5.1.11 in the reference doc):

<many-to-one name="Department" class="Department" column="Employee_Num" unique="true"/>

_________________
--Wolfgang


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.