I got to the bottom of this. Because the HQL statement is using .List<Cutting>() , even though I specified the first index, it does query all of the entities for which the headline field contains 'today'. Amongst them, some had a null date field and I was getting the exception described here : http://ayende.com/Blog/archive/2007/03/26/NHibernate-Nullable-DateTime-Issues.aspx
This raises another question : I've specified the first index, so why other records were even considered by NHibernate ?? On 10 mar, 17:57, graphicsxp <[email protected]> wrote: > I'm retrieving an entity from my database by doing : > > tx = provider.Session.BeginTransaction(); > > c = provider.getCuttingById(177040); > > tx.Commit(); > > In the sql generated by NHibernate, there's only a select statement > retrieving my entity (of type Cutting). > > However if I do that : > > Cutting cuttings = provider.Session.CreateCriteria(typeof > (Cutting)).SetFetchMode("thePublication", FetchMode.Eager).Add > (Expression.Like("Headline", "%today%")).List<Cutting>()[0]; > > That returns the same Cutting entity along with a many-to-one Entity > property of type Publication. > > But this time when I execute tx.Commit(), NHibernate generates a > UPDATE statement ! That doesn't make sense because I'm not modifying > anything here .... > > Hope this is clear enough... Could someone explain ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
