• HasMany and null foreign key columns

    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

    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

    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.