Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
NHibernate 4.x Cookbook

You're reading from   NHibernate 4.x Cookbook Over 90 incredible and powerful recipes to help you efficiently use NHibernate in your application

Arrow left icon
Product type Paperback
Published in Jan 2017
Publisher Packt
ISBN-13 9781784396428
Length 448 pages
Edition 2nd Edition
Arrow right icon
Authors (4):
Arrow left icon
 Liljas Liljas
Author Profile Icon Liljas
Liljas
Darshan Joshi Darshan Joshi
Author Profile Icon Darshan Joshi
Darshan Joshi
 Zaytsev Zaytsev
Author Profile Icon Zaytsev
Zaytsev
Jason Dentler Jason Dentler
Author Profile Icon Jason Dentler
Jason Dentler
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

NHibernate 4.x Cookbook Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. The Configuration and Schema FREE CHAPTER 2. Models and Mappings 3. Sessions and Transactions 4. Queries 5. Improving Performance 6. Testing 7. Data Access Layer 8. Extending NHibernate 9. NHibernate Contribution Projects Index

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 reason. The concept itself is known as sharding and is used in many large scale applications, such as Facebook.

In this recipe, we'll show you how to use NHibernate.Shards to split our data set across three databases.

Getting ready

In SQL Server, create three new, blank databases named Shard1, Shard2, and Shard3. Complete the Getting Ready instructions at the beginning of Chapter 4, Queries.

How to do it...

  1. Add a reference to NHibernate.Shards using NuGet Package Manager Console:

    Install-Package NHibernate.Shards –Project QueryRecipes
    
  2. Add a new folder named Sharding to the project:

  3. Add a new embedded resource named ShardedProduct.hbm.xml:

    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
      assembly="QueryRecipes"
      namespace="QueryRecipes.Sharding">
      <class...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images