There 3 mapping patterns to map a one-to-one. Just one for unidirectional relation Two for bidirectional (oen through PK the other through FK).
Which is your case? -- Fabio Maulo El 15/11/2010, a las 16:25, Scott <[email protected]> escribió: > A little more I discovered after testing. > > It doesn't matter if the Child is null, I added the records and it > still does the same thing. > > And it only happens the 2nd time through, the first time everything is > fine, the 2nd time and the query is wrong doing the exact same thing. > > > > On Nov 15, 10:51 am, Scott <[email protected]> wrote: >> I have a one-to-one relationship and when the child table is null for >> the main object the SQL query that's created is wrong, it gives it a >> parameter of the primary key but it never uses this parameter in the >> query itself. This causes it to return all records in the table and a >> "More than one row with the given identifier was found" error when >> actually it shouldn't be finding anything. >> >> Parent has: >> <one-to-one name="Profile" class="DatabaseModel.Models.UserProfile, >> DatabaseModel" cascade="all" property-ref="UserInfo" /> >> >> Child has: >> <one-to-one name="UserInfo" class="DatabaseModel.Models.UserInfo" >> cascade="delete" constrained="true" /> >> >> The query that gets generated is: >> exec sp_executesql N'SELECT userprofil0_.UserInfoRefId as >> UserInfo1_4_0_, userprofil0_.Version as Version4_0_, >> userprofil0_.CurrentRosmatRefId as CurrentR3_4_0_ FROM UserProfile >> userprofil0_',N'@p0 uniqueidentifier',@p0='60E9764B- >> D48E-4260-81BC-308B3486851F' >> >> Notice the lack of a WHERE clause >> >> This is what I think it should be: >> exec sp_executesql N'SELECT userprofil0_.UserInfoRefId as >> UserInfo1_4_0_, userprofil0_.Version as Version4_0_, >> userprofil0_.CurrentRosmatRefId as CurrentR3_4_0_ FROM UserProfile >> userprofil0_ WHERE userprofil0_.userinforef...@p0',N'@p0 >> uniqueidentifier',@p0='60E9764B-D48E-4260-81BC-308B3486851F' >> >> This is on NHibernate 2.1.2 > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" 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/nhusers?hl=en. > -- You received this message because you are subscribed to the Google Groups "nhusers" 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/nhusers?hl=en.
