-->
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: Many to One with the "One" side non-existent...
PostPosted: Thu Jun 23, 2005 4:42 pm 
Newbie

Joined: Mon Jun 06, 2005 3:36 pm
Posts: 5
I have somewhat of a weird case here.

I have a "pseudo" foreign key that always keep it's value even when the parent is deleted. Don't ask, I'm not the one who design it...

I first tried to model the relation as a many-to-one on the child side, but some "missing parents" are causing problems...

I'm now thinking about going to read that parent independentely when ever I need to display the parent information, so that I can handle the "missing parent" manually, instead of specifying it as "many-to-one" relation in NHibernate.

Before I start doing so, since I'm new with NHibernate, I thougt I would post my little problem here to see if that would be the logical way to go. My program won't ever (well, that I know for now) be modifying the parent side (only the child side), I only need to be able to access the parent, when-ever it is available, for display purpose.

So, am I going the right way?

Thank's in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 11:02 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Jumpin'Jack Flash wrote:
I have a "pseudo" foreign key that always keep it's value even when the parent is deleted.


I don't know if it is possible... When loading a child, if the identifier of the <many-to-one> is not null, then NHibernate will try to load it...

How do you know when the value of this "pseudo" foreign key is "valid" (=> linked to a real parent) ? (you trying to load and if it fail, you know it is invalid !?!)

In your database, this "pseudo" foreign key is defined as a classic column; no ? (You will probably end up creating the relation yourself)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 11:43 am 
Newbie

Joined: Mon Jun 06, 2005 3:36 pm
Posts: 5
It is exactly like you say.

The relation from the child to the parent will always have a non-nul value. But the parent might not be on the other end. If it's not, I'll display the "foreign key value" only, if not, I can display more about it...

So it look like that I'll have to handle this "manually"...


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.