My bad, SpecialUser and SpecificUser are a little close for my post-midnight brain to differentiate.
On 12/15/09, Ethan <[email protected]> wrote: > James, I believe you mean this post: > http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/603a3851b4122468. > That wasn't me. I made an honest typo in this post. > > On Dec 14, 4:09 pm, Ethan <[email protected]> wrote: >> Yes the above is pseudocode, however it should be >> SubClassMap<SpecialUser>, it's written incorrectly in my first post. >> >> On Dec 14, 4:06 pm, Hudson Akridge <[email protected]> wrote: >> >> >> >> > Hoping the above is pseudocode, because you're mapping ID's as >> > properties >> > instead of identities. >> >> > Also you've got your inheritance set up to be: >> > : SubClassMap<User> >> >> > and I believe it should be: >> > : SubClassMap<SpecialUser> >> >> > That would explain why it thinks your status property is on the base >> > User's >> > table instead of the SpecialUser's table. >> >> > On Mon, Dec 14, 2009 at 5:59 PM, Ethan <[email protected]> >> > wrote: >> > > I've got a set of mappings like this: public class UserMap : >> > > ClassMap<User> >> > > { >> > > public UserMap() >> > > { >> > > Map(x => x.Id); >> > > Map(x => x.Status); >> > > } >> > > } >> >> > > public class SpecialUserMap : SubClassMap<User> >> > > { >> > > public SpecialUserMap() >> > > { >> > > Map(x => x.Property); >> > > } >> > > } >> >> > > public class DirectoryMap : ClassMap<Directory> >> > > { >> > > public DirectoryMap >> > > { >> > > Map(x => x.Id); >> > > HasMany(x => x.SpecialUsers).Where("Status = 0"); >> > > } >> > > } >> >> > > where User is a join map, and SpecialUser joins against it to get >> > > things like Status. I can't get the DirectoryMap to work, since >> > > accessing Directory's SpecialUsers collection causes a "undefined >> > > column Status" error, as NHibernate can't figure out that the Status >> > > column comes from the User table, and not the SpecialUser table. >> > > Is there a way to manually tell NHibernate which column to look at? >> >> > > Another possible solution I thought of is to throw a subselect SQL >> > > statement into the Where clause, but NHibernate tends to do this: >> >> > > Where("SELECT u.Status FROM User WHERE u.Id = Id) generates select >> > > <columns> from [SpecialUser] specialuse0_ inner join [User] >> > > specialuse0_1_ on <id = id> WHERE (SELECT u.Status FROM >> > > specialuse0_.Status = 0) >> >> > > Basically it treats my variables as columns from the SpecialUser >> > > table, and inserts specialuse0_ into the SQL instead. >> > > If there is a way to make NHibernate not touch the SQL inserted in the >> > > Where clause that might be a possible solution (albeit not a good one) >> > > as well. >> >> > > -- >> >> > > 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]<fluent-nhibernate%2Bunsubscr >> > > [email protected]> >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/fluent-nhibernate?hl=en. >> >> > -- >> > - Hudsonhttp://www.bestguesstheory.comhttp://twitter.com/HudsonAkridge > > -- > > 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. > > > -- 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.
