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.  [ 1 post ] 
Author Message
 Post subject: multi-relation tables (one-to-one and one-to-many)
PostPosted: Tue Apr 15, 2008 5:25 pm 
Newbie

Joined: Tue Apr 08, 2008 6:24 am
Posts: 8
How would I map the below table schema?

Below is a simplified example of a schema I'm trying to map in NHibernate

table:
- company_details
columns:
- some details....
- co_pk (identity)
- manager_fk_person_details (foreign key to person_details pk)
- senior_manager_fk_person_details (as above)

table:
- person_details
columns:
- ex_pk (identity)
- ex_type (type = 1 or 2 when one to one and type = 3 for a collection)
- ex_fk_company_details (foreign key to company_details pk)

then the classes would be:

Code:
public class company_details
{

public virtual int Id
{
set {}
get {}
}

public virtual PersonDetails Manager
{
set {}
get {}
}

public virtual PersonDetails SeniorManager
{
set {}
get {}
}

public virtual IList<PersonDetails> Employees
{
set {}
get {}
}
}


the above is just an example that I have come up with so please execuse code or table errors.

How would I go about implementing the above as I have tried to use discriminators (for ex_type) which works for the list of employees but don't know how to do the one-to-one

Please can someone help me as I have ran out of ideas.

Thanks for any help in advance.
Code:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.