the error is not a SQL error, but an NH errormeaning - it's referring to the *property* [name] on the *class* [HelloNHibernate.Employee] I guess that the property name is [Name], not [name], so the HQL is misspelled.
Am I correct? On Sun, Feb 15, 2009 at 3:39 PM, Peter Morris <[email protected]> wrote: > > > Whatever your opinions on the book may be, it wouldn't hurt to read ahead > > a > > paragraph or two before calling on our help. > > I thought I was reading an "in action" book not an "in theory" book. At > the > point it shows me the code to load/save objects I would have expected it to > be capable of loading and saving objects. > Considering I have never used NH before it is difficult to know whether > > A: I have messed up the steps in the book. > B: The book is wrong. > C: Everything has changed because NH is open source and gets updated often > > I don't think I have ever read a book where the example code given doesn't > work because there are additional steps to complete later in the book > before > it is complete, at least not without mentioning it. As a consequence I > have > never experienced this scenario before and it didn't even occur to me to > continue reading a few more pages to see if the code I have just been told > to put in is "fixed" later. > > No sooner am I past the first obstacle I now see the following error > > "could not resolve property: name of: HelloNHibernate.Employee [from > HelloNHibernate.Employee as emp order by emp.name asc]" > > static void LoadEmployeesFromDatabase() > { > using (ISession session = OpenSession()) > { > IQuery query = session.CreateQuery("from Employee as emp order by > emp.name asc"); **HERE ** > IList<Employee> foundEmployees = query.List<Employee>(); > Console.WriteLine("\n{0} employees found:", > foundEmployees.Count); > foreach (Employee employee in foundEmployees) > Console.WriteLine(employee.SayHello()); > } > } > > I have no idea why it is selecting HelloNHibernate.Employee rather than > dbo.Employee or just "Employee". I've scanned ahead in the book and this > one is not addressed later, so if someone can explain this to me I'd > appreciate it. > > > Thanks > > > Pete > ==== > http://mrpmorris.blogspot.com > http://www.capableobjects.com - Think domain, not database > > > > > > > > On Sun, Feb 15, 2009 at 1:12 PM, Peter Morris <[email protected]> > wrote: > > > >> > >> > Are you referring to "Hello World" with NHibernate? Because if you > are, > >> > there are more steps after the one you're talking about. 2.1.5 creates > >> the > >> > code to save, then it carry's on explaining things until you get to > >> > 2.1.8 > >> > where you actually configure your application. > >> > >> Yes I am, and I am already really regretting spending the money! > >> > >> 2.1.5 = App code to write an employee to the DB > >> 2.1.6 = App code to fetch the employee back from the DB > >> 2.1.7 = How to write the mapping code to make 2.1.5 and 2.1.6 work > >> > >> What? Whatever happened to building stuff up in stages? > >> > >> *Sigh* > >> > >> I hope things are down hill from here onwards. This is painful! > >> > >> > >> Pete > >> ==== > >> http://mrpmorris.blogspot.com > >> http://www.capableobjects.com - Think domain, not database > >> > >> > >> > > >> > > > > > > > > > > > > -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
