Data Access
So, I've been doing things slightly differently on this project as opposed to the past few and I'm starting to hit some "quirks". The biggest difference is that I'm now taking more control in my mapping files. In the past I specified only the mapping values that I knew needed to be a particular way. This time I tried tinkering further, and the test project caught my mistakes and threw them in my face:
https://docs.google.com/leaf?id=0B7jSfuxfxwTLYTY5YzVkOTctMGM1YS00OWM1LWI5NjItM2VmY2JhNmRjMTNi&hl=en
Link above for the latest version. I have moved some things around and fixed a few problems found in the mappings and domain objects that were uncovered in testing. Right now, the newly added stuff is very small. I wanted to keep moving on this project, so even just a couple dozen new lines is feeling like a good thing at the moment. I'm sore and tired from the camping trip, and this small amount of terrible code is looking glorious right now.
What's important about this little bit of extra code is that it generates the database for me based on the schema defined in the domain objects and my mapping files and the tester runs it without crashing. Also, the second test tries to insert a few items just so that we know for a fact that it actually worked without the need to dig into the database with another tool verify that structure and contents.
This is where on of the quirky things I mentioned popped up. For the hell of it, when I was debugging I added a Category and a Recipe, then I added the Recipe to the Category and reloaded both objects, but the entry in the many-to-many table did not get updated. NHibernate cached the fact they the category has a recipe added, but the recipe object wasn't updated. This will merit some digging into the code. I can't have this sort of strange activity going on :)
Anyway, I used SQLite for the database this time around again. So for this example you need to download the DLL, add it to the project and set the "Copy Local" property to "True". Or if you're adventurous you can download the necessary file for whatever other database and tweak the code to use that one instead.
Time to check on my mead before bed. (Started a few days after I started this blog, going well, hopefully better than last time).
Alex.
https://docs.google.com/leaf?id=0B7jSfuxfxwTLYTY5YzVkOTctMGM1YS00OWM1LWI5NjItM2VmY2JhNmRjMTNi&hl=en
Link above for the latest version. I have moved some things around and fixed a few problems found in the mappings and domain objects that were uncovered in testing. Right now, the newly added stuff is very small. I wanted to keep moving on this project, so even just a couple dozen new lines is feeling like a good thing at the moment. I'm sore and tired from the camping trip, and this small amount of terrible code is looking glorious right now.
What's important about this little bit of extra code is that it generates the database for me based on the schema defined in the domain objects and my mapping files and the tester runs it without crashing. Also, the second test tries to insert a few items just so that we know for a fact that it actually worked without the need to dig into the database with another tool verify that structure and contents.
This is where on of the quirky things I mentioned popped up. For the hell of it, when I was debugging I added a Category and a Recipe, then I added the Recipe to the Category and reloaded both objects, but the entry in the many-to-many table did not get updated. NHibernate cached the fact they the category has a recipe added, but the recipe object wasn't updated. This will merit some digging into the code. I can't have this sort of strange activity going on :)
Anyway, I used SQLite for the database this time around again. So for this example you need to download the DLL, add it to the project and set the "Copy Local" property to "True". Or if you're adventurous you can download the necessary file for whatever other database and tweak the code to use that one instead.
Time to check on my mead before bed. (Started a few days after I started this blog, going well, hopefully better than last time).
Alex.
Comments
Post a Comment