NHibernate Templates for Smart Code Generator

Danilo Mendez has an article showing the Smart Code Generator that creates NHibernate template libraries.

This is incredible work, I am using NHibernate Best Practices w/ASP.NET, 1.2nd Ed. by Billy McCafferty – which I have really found to be a good architecture – and this tool helps with the generation of these templates.

Great work Danilo!

Advertisements

2 thoughts on “NHibernate Templates for Smart Code Generator

  1. I am also working on a team on CodePlex as the lead to use the same technology base but to allow the far more effective ‘NHibernate Mapping Attributes’.

    I know Billy and love his work and agree his article has done so much to help the ’cause’. He speaks for the masses, rather then far too many NHibernate guys who pull attitude all the time and want that learning curve to stay as steep as possible.

    However where we may differ is to me it is an imperitive to use the ‘mapping attributes’ as it is far less work and is far more conducive to iterative development, with no ‘XML Generators’.

    Less work?

    Here is why:

    1) Class X – Proprty Y maps to column A

    [Property]
    public String CustName {….}

    That is it. It sniffs all the type info for you. Ah the names are different?

    [Property(Column=”CustName”)]
    public String FullName {….}

    This ends up saving a boat load of time as you can use typeof(…) for early compiler error detection. Try that with XML! F5, crash, fix, F5…. No more!

    And if you really love the XML, it gets generated and you can store it off, then use that until something changes, perhaps doing an automated system. They recommend doing this for performance and I have never needed to with over 500 entities. For web apps, who cares if startup is 20 seconds longer..

    Basically what our CodePlex project is doing is generating similar templates (Billy and I do differ on some items, for example I am a hard-core believer that any Domain Class should never be forced to inherit from anything or implement any interface… Call me old school – or perhaps new school – who knows)…

    So in closing if you or anyone is interested this is what we are doing on CodePlex:

    1) Generating skeletal code which is 100% Attribute based with the only use of a mapping file used for imports (as that is about the only thing finally you must do in XML).

    2) Also synchronizing Assemblies via reflection (from these attributes) to the amazing SharePoint 2007 Enterprise Business Data Catalog.

    Kind Regards,
    Damon Carr, CTO
    agilefactor

  2. Thanks Damon, I am glad to see this work! I’ve been reading the NHibernate in Action pre-order pdf that I purchased and I know he has made a point to show both attributes and xml. I hadn’t realize you could use attributes before I read that.

    I have used Active Record by Castle which uses attributes and it is easier to troubleshoot.

    Thanks again and be sure to send me a link to your codeplex project, I’m very interested in seeing more of it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s