A blitz through nhibernate slides

Download Report

Transcript A blitz through nhibernate slides



Who I am
What is NHibernate?
◦
◦
◦
◦
◦
Object Relational Mapper
A framework for building advanced frameworks
Ported from Java
A wide NHibernate ecosystem now exists
Why ORMs?






Download and add necessaryreferences
Intellisense
Show common exceptions
Configure mapping files
Configure configuration files
Create repository
Custom defined mappings
ICompositeUserType
Core API
IUserType
Configuration
Instrumentation
Statistics
ISessionFactory
Interception
IEventListener
ISession
IInterceptor
ITransaction
Querying
ICriteria
IQuery





Many-to-one
Cascading
One-to-many
Components
Assigned keys

Table per class hierarchy
◦ One table represents an aggregate
◦ Simple and good performance wise
◦ Loss of not-null constraints

Table per concrete class
◦ One table for each non-abstract class
◦ Can be problematic for polymorphic queries

Table per subclass
◦ Completely normalised
◦ Polymorphic queries possible




NamingStrategy
IUserType
ICompositeUserType
Should be an exception more that the rule


Event listeners
Interceptors
◦ Refer to empty interceptor implementation
◦ Refer to profiler interceptor setting





HQL
ICriteria API
Query By Example (QBE)
Linq to NHibernate
Straight SQL

New feature added at NHibernate 2.0
Exists at both SessionFactory and Session
Must turn statistics on, off by default

Refer to SessionFactoryStatisticsBuilder



First level Caching
◦ Default caching level
◦ Caching at the session level

Second level Caching
◦ Must be configured at Configuration and entity
itself
◦ Caching at the session factory level
◦ Providers such as memcached, nvelocity supported