Read the difference between Load and Get http://nhforge.org/doc/nh/en/index.html#manipulatingdata-loading
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Tomasz Modelski (IDev) Sent: den 19 februari 2010 13:21 To: nhusers Subject: [nhusers] Re: Session.Load<TEntity>(id) if id doesn't exist behavior John. When lazy=true on class level, Load(34534535) exception is not thrown. [34534535 - some not existing id]. But exception is thrown when I access returned entity proxy id property - that's the difference, when Load(0) - returned proxy has id=0 value. On 19 Lut, 13:05, John Davidson <[email protected]> wrote: > Id = 0 is a special case in NHibernate unless you specify differently using > the 'unsaved-value' attribute in the 'id' property of your entity mapping > file. > > What happens when you try Sessio.Load<TEntity>(1001>? > > John Davidson > > On Fri, Feb 19, 2010 at 6:46 AM, Tomasz Modelski (IDev) < > > [email protected]> wrote: > > Hi. > > > As I understand, Session.Load<TEntity>(id) should return proper entity > > or throw exception if entity with such id doesn't exist. > > Is it true ? > > > Right now I'm debugging code when Session.Load<TEntity>( 0 ) returns > > not-null and doesn't throw exception, and there is not TEntity with id > > 0 in database. > > Returned object is some TEntity proxy with properties throwing > > exceptions when accessed. > > > I'm using NHibernate v. 2.1.2.4000. > > > -- > > 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]. 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.
