You have another option if FNH does not support access="readonly". Ask the feature to FNH team ;)
2010/2/18 Robert Rudduck <[email protected]> > You could set the access to use a private field and not put a setter on the > property. ReadOnly means that any update wont be written out, but it still > requires a setter of some sort so NHibernate can initialize it. > > > On Thu, Feb 18, 2010 at 2:12 AM, Alex McMahon <[email protected]> wrote: > >> Intereting... I know this is sort of the wrong place to ask, but how >> do I do this in Fluent NH? I've tried .ReadOnly() but I then get an >> error message about there not being a setter... I've also tried. >> Access.<various> but there doesn't seem to be one called ReadOnly... >> any ideas? >> >> On Feb 17, 11:29 pm, Fabio Maulo <[email protected]> wrote: >> > access="readonly" >> > >> > 2010/2/17 Alex McMahon <[email protected]> >> > >> > >> > >> > > Fabio, >> > >> > > Thanks for your reply... I don't quite understand what you mean... I >> > > think you're saying "how can NH know that it needs to put something in >> > > the DB if you don't tell it to". I see what you're saying >> > > (particularly as it's not just a default canned value that needs to go >> > > in). I guess what I want is to be able to map a property that has a >> > > getter only by specifying an access strategy that results in the >> > > property just being persisted to the database on an insert but doesn't >> > > try to set the property from the DB on a read... >> > >> > > Thanks >> > >> > > On Feb 17, 3:35 pm, Fabio Maulo <[email protected]> wrote: >> > > > Have you an idea about from where NH can know/read to write in the >> FK ? >> > >> > > > 2010/2/17 Alex McMahon <[email protected]> >> > >> > > > > I have a legacy database that I'm restricted from changing. I have >> 2 >> > > > > related tables that both have a foreign key to the same 3rd table. >> In >> > > > > my application I'd rather not have this relationship repeated on >> both >> > > > > classes. But when I don't map this relationship for both classes I >> get >> > > > > problems as NHibernate does not put the foreign key in the >> database. >> > >> > > > > I'd like it to be like this: >> > > > > TableA: >> > > > > TableBId >> > > > > TableCId >> > > > > (other fields) >> > >> > > > > TableB: >> > > > > TableCId >> > >> > > > > ----- >> > >> > > > > ClassA: >> > > > > ClassB B >> > > > > ClassC C >> > >> > > > > ClassB: >> > > > > (other fields) >> > > > > //I don't want ClassC referenced here. >> > >> > > > > Any idea how I can tell NHibernate to write the foreign key for >> TableB- >> > > > > >TableC on an insert, with the minimal amount of pollution of my >> > > > > domain model. >> > >> > > > > -- >> > > > > 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]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > >> > > > > . >> > > > > For more options, visit this group at >> > > > >http://groups.google.com/group/nhusers?hl=en. >> > >> > > > -- >> > > > Fabio Maulo >> > >> > > -- >> > > 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]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/nhusers?hl=en. >> > >> > -- >> > Fabio Maulo >> >> -- >> 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]<nhusers%[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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > -- Fabio Maulo -- 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.
