O'Reilly logo

NHibernate 3.0 Cookbook by Jason Dentler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sharding databases for performance

There are a few scenarios where it may be appropriate to partition data horizontally across several servers, with performance being the most obvious. In this recipe, I'll show you how we can use NHibernate Shards to split our data set across three databases.

Getting ready

  1. Download the latest NHibernate Shards binary from SourceForge at http://sourceforge.net/projects/nhcontrib/files/.
  2. Extract NHibernate.Shards.dll from the downloaded ZIP file to your solution's Lib folder.
  3. Complete the Eg.Core model and mappings from Chapter 1.
  4. In SQL Server, create three new, blank databases named Shard1, Shard2, and Shard3.

How to do it...

  1. In the Entity base class, change the type of the Id property from Guid to String.
  2. In Product.hbm.xml ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required