NHibernate. Object/Relational Persistence for .NET. A little bit of background information…. .NET port of the Hibernate project (Java). Mature architecture and proven c oncepts, already in use in many enterprise Java applications. Already quite popular in the .NET world as well.
Object/Relational Persistence for .NET
Mature architecture and proven
concepts, already in use in many
enterprise Java applications
General Philosophy Of NHibernate
It’s all about POCO
Should work on most databases
Full OO support: inheritance, polymorphism, composition, single-valued and many-valued associations
Maximize performance and flexibility single-valued and many-valued associations
Keep your code clean single-valued and many-valued associations
Strong Points single-valued and many-valued associations
Database independence layers, …)
Rich feature set layers, …)
Mature layers, …)
Extensible architecture layers, …)
Large, active, helpful and growing user base layers, …)
It’s Open Source (LGPL)! layers, …)
Weak Points layers, …)
Not suited (at all) for bulk data processing layers, …)
Bad reputation in some companies due to layers, …)
lazy coding ( = abuse of lazy loading )
Plenty of layers, …)outdated articles, blog posts and documentation available
It’s Open Source! layers, …)
(some companies just don’t like that)
Let’s look at some of the things we can do with layers, …)NHibernate…
Transitive Persistence layers, …)
Managing associations between classes layers, …)in a transparent manner
Needs to be configured for each association layers, …)
=> fine-grained control over cascade settings
Hold on… why was every member in the Order layers, …)
I wouldn’t want to debug that either :) layers, …)
Storing data in the database in an easy manner is great and all, but what about getting it out again?
Querying with all, but what about getting it out again?NHibernate
Hibernate Query Language all, but what about getting it out again?
It’s an Object Oriented query all, but what about getting it out again?language
Criteria API all, but what about getting it out again?
Makes it easier to compose queries dynamically from code. all, but what about getting it out again?
LINQ… still not fully supported all, but what about getting it out again?
Wouldn’t it be great if we could execute multiple queries in only one database roundtrip?
Future Queries in only one database roundtrip?
As of as well?NHibernate 2.1, we can do this with some new HQL statements
Data Modification With HQL as well?
Of course not :) as well?
Second Level Cache as well?
Second Level Cache data is as well?available to
We can cache entity instances… as well?
This is ideal for static (reference) data or even data that doesn’t change frequently
How does the cache deal with modified data, though? doesn’t change frequently
We’ll update the database doesn’t change frequentlyand the cache
NHibernate doesn’t change frequently will never cache anything in the Second Level Cache automatically
It doesn’t change frequentlyneeds to be configured on a per-entity and per-query basis
A doesn’t change frequentlyll the caching power you want, without having to pollute your code
That’s up to you… multiple providers are available: ASP.NET cache, MemCached, Velocity, Prevalence, …
At this point, I’m ASP.NET cache, almost running out of time and there is a lot more interesting stuff that we won’t get to cover.
Like optimistic concurrency strategies… ASP.NET cache,
Or pessimistic ASP.NET cache, locking strategies…
Or the various identifier strategies… ASP.NET cache,
Or the various inheritance strategies… ASP.NET cache,
Or how automatic dirty tracking works… ASP.NET cache,
Or how you can implement your own dirty tracking… ASP.NET cache,
Or custom user types… ASP.NET cache,
Maybe some other time :) either…
If you want to learn more, be sure to visit http://nhforge.org
Oh, and check out my blog if you liked this presentation: http://davybrion.com