NHibernate Screencast - Persisting the Address Book
Thursday, November 15 2007 9 Comments
A few weeks ago, Evan Hoff posted a screencast on building up a domain model in a test-first manner. We talked about it and thought it might be interesting to show how to apply persistence to this already functioning and tested domain model.
So take a look and tell me what you think! It weighs in at 40 minutes (I tried to keep it under 30 but hey).


Jose
11.15.2007
2:23 PM
Hey Ben, you are the man !!that was a pretty cool screencast, i've been learning NHibernate at work because of a this new project and my boss can't wait until .NET 3.5, anyway I didn't know that NHibernate would actually crated the DDL for your objects, that is way cool.Yesterday i was trying to setup a few scenarios and manage to make NHiberanmte Insert,update, and delete and POCO (Person class) to the DB which directly maps to a ONE table "Person" table so that was pretty simpleThe problem tha I also had another POCO that Derives from Person which is "Staff" so basically the "Staff" Class has a few extra properties along with the properties for "person" class: example:Person(Firstname, LastName)Staff(Email, Title) and also the properties from Person since Staff inherits from Person.I wanted to Create 2 tables in the DB one called Person and one called Staff, and basically the "staffId" would be the same of a Person Id if there was a staff to bein the DB (does that makes sense)?So to select A staff, there needs to be a Select Statement from person table and staff table that joins on personid = staffid, same is true for updates/deletes/selectsHow can i Map The "Staff" POCO which inherits from Person, and Map that to tell NHibernate to use 2 Tables the "person" and "staff" table for Inserting, updating and deleting a "Staff" POCO ??????? HOw can i do that in NHibernamte?????????Please tell me is pretty simple to do? right?What about a Class that needs to be mapped to 3 tables? Like "SalarayEmployee" which inherits from "Staff" which inherits from "Person"AM I Crazy or what?