HasMany and null foreign key columns

Tuesday, 26 August 2008

I’ve been trying to figure out why our data layer wasn’t saving a new item that we’d added to a [HasMany] collection.

To figure out what was happening, I build a simple sample based on the examples from the Castle ActiveRecord documentation.

ClassDiagram1

This generates a database schema like this:

BlogPostTableDiagram

Normally you’d make the foreign key column ‘blogid’ not null, but (as mentioned in this thread) for NHibernate, it does an INSERT then an UPDATE so the foreign key column does need to be nullable.

I can understand this might be the case if the Blog entity hadn’t been saved, but it is surprising that it doesn’t recognise that it could use a single INSERT statement if it does know the foreign key value.

NHibernate 2.0 GA

Monday, 25 August 2008

Fabio announced that version 2.0 of NHibernate is now released. This is great timing, as we’ve been using the release candidate for a few weeks now.

Download from SourceForge.

Unfortunately this release doesn’t include LINQ for NHibernate, but the word on the street is that is planned for 2.1. That will be a really useful addition. I’d much prefer to use LINQ to write queries and let the compiler check the syntax rather than have HQL strings that I only find out at runtime are incorrect.

UrlScan v3.0

Friday, 22 August 2008

Version 3.0 of this useful filter has been released. Just the thing to help keep the nasties out of your IIS server.

Nazim summarises the new features.

And the winner is…

Thursday, 21 August 2008

Last night the SA finals of Microsoft’s Demo competition were held. The state finalists were:

Andrew Coates hosted the show (well there were only the five of us there, so it was a small show) and also judged the presentations. At the conclusion, Andrew announced that Nigel was the winner!

After we posed for a photo in our very trendy bright orange T-shirts, Andrew then took us out to dinner along with Darren Neimke (who happened to be in the neighbourhood).

It was a great night, and all the best for Nigel in the national finals to be held at TechEd 2008 in Sydney in a couple of weeks.

Sticky taped

Monday, 18 August 2008

Taped I obviously haven’t been as productive as my ABB colleagues thought I should be, so they kindly taped up my mouse – presumably to encourage me to use the keyboard more.

I’m not sure what they’re saying by taping up my phone and my chair though.

Or maybe things just got extra silly on Friday afternoon after I left :-)