If you do a one-to-on, be sure that one of your one-to-one's (usually the
"dependent" side, in your case the UserPreferences) has it's Id set to:
GeneratedBy.Foreign(), and then specify the property name of the one-to-one.
James is spot on though. You probably mean a many-to-one. one-to-one's are
extremely rare. I've used them once in a production  environment, and it
ended up being a mistake that we rolled back a couple of weeks later. In
some extreme cases, with the way cascades work on many-to-one's, you may end
up having to do a collection that will only ever have one element. For
example, a state engine. This is because swapping many-to-one's out (i.e.
changing states), is not always guarenteed to delete the original reference
in the database, so you end up with either FK violations, or orphans.

In the cases where I've actually seen a one-to-one being used, it's usually
with bad class design, and they've got two classes doing what one class
should be doing.

On Sat, May 23, 2009 at 10:34 PM, [email protected] <[email protected]
> wrote:

>
> Hi,
>
> Can someone direct me on how to create a simple one-to-one mapping.
> Below shows the names of the classes, and the .hbm mappings I used.
> I'm hoping there is a Fluent version of this.. :)
>
> Thanks in advance.
> Greg
>
>
> UserProfile {
>        <one-to-one name="UserPreferences" class="UserPreferences"
> cascade="all"/>
> }
>
> UserPreferences {
>        <one-to-one name="UserProfile" class="UserProfile"
> constrained="true"/>
> }
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to