Why Future<T> should be in your future

November 16th, 2009

Even though NHibernate 3.0 is on the way I am going to highlight a feature that was introduced in v2.1 but that relatively few people seem to be using (at least in the code bases I have seen recently). Former ECer Davy Brion, as always, does an excellent job of demonstrating usage of the feature here so I am not going to rehash that. What I am going to focus on here if the why.

Building a UI can be a very database intensive operation in terms of the number of separate calls required. And for each one of those calls the time taken to actually execute the query can be a small compared to the duration of the roundtrip to request and fetch the data. The obvious solution is some type of batching and with Future<T> this happens automagically without any change to the consuming logic (for databases that support it). Let me restate that, you get a huge performance benefit with only a simple change to your query methods in the Repository. So why aren’t you using it?

Jason Grundy NHibernate

  1. RichB
    November 18th, 2009 at 04:54 | #1

    > So why aren’t you using it?

    It’s only supported on MSSQL.

  2. November 18th, 2009 at 05:46 | #2

    @RichB

    it also works on MySQL, PostgreSQL, SQLite, and SQL Server CE

  1. No trackbacks yet.