session.Get() - Load() just returns a proxy which then gets lazily initialised
/Pete From: [email protected] [mailto:[email protected]] On Behalf Of Felipe Oriani Sent: 09 April 2013 03:23 To: [email protected] Subject: Re: [nhusers] Mapping SaveUpdate Reference (HasOne) When I update the instance I was not loading before update, so the Id was 0. So, I load it before update and now it works fine, but is that right? What is the recomendation before update an entity? Load with session.Load<T> or session.Get<T>? Thank you. On Mon, Apr 8, 2013 at 9:44 PM, Gunnar Liljas <[email protected]> wrote: The mapping looks OK, so I think there's something more to the story. Either the mappings or some accidental replacing of the Address instance. /G 2013/4/8 Felipe Oriani <[email protected]>: > Hi, > > I am using Fluent NHibernate to map my entities on my project. I have a > model that has a relation by one and the Id of this relation is on the main > entity. For sample: > > public class Customer > { > public Address Address { get; set; } // address Id is on this table > } > > public class Supplier > { > public Address Address { get; set; } // address Id is on this table > } > > public class Address > { > // fields of this entity > } > > When I get Save a Customer or Supplier entity on my session, the Address is > save together on the database, but when I Update these same entities, it > does not work, It create a new instace of the Address on my address table. I > would like to update the address instead create a new one. > > I am mapping using this: > > References((x) => x.Address).Columns("ADRRESS_ID").Cascade.All(); > > Thank you > > -- > ______________________________________ > Felipe B Oriani > felipeoriani.com.br [email protected] > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <mailto:nhusers%[email protected]> . > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/nhusers?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:nhusers%[email protected]> . To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- ______________________________________ Felipe B Oriani felipeoriani.com.br <http://felipeoriani.com.br/> [email protected] -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
