1 / 11

A blitz through NHibernate

Explore NHibernate ORM, its API, querying methods, customization options, mapping strategies, querying techniques, caching levels, and more. Download and add necessary references, configure files, and create custom mappings with NHibernate. Learn about NHibernate's rich ecosystem and its advantages.

alatoya
Download Presentation

A blitz through NHibernate

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A blitz through NHibernate

  2. Introduction • 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?

  3. Simple NHibernate example • Download and add necessaryreferences • Intellisense • Show common exceptions • Configure mapping files • Configure configuration files • Create repository

  4. Custom defined mappings NHibernate API ICompositeUserType Core API IUserType Configuration Instrumentation Statistics ISessionFactory Interception IEventListener ISession IInterceptor Querying ITransaction IQuery ICriteria

  5. A more complex mapping • Many-to-one • Cascading • One-to-many • Components • Assigned keys

  6. Mapping class inheritence • 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

  7. Customisation • NamingStrategy • IUserType • ICompositeUserType • Should be an exception more that the rule

  8. Interception • Event listeners • Interceptors • Refer to empty interceptor implementation • Refer to profiler interceptor setting

  9. Querying • HQL • ICriteria API • Query By Example (QBE) • Linq to NHibernate • Straight SQL

  10. Statistics • New feature added at NHibernate 2.0 • Exists at both SessionFactory and Session • Must turn statistics on, off by default • Refer to SessionFactoryStatisticsBuilder

  11. Caching • 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

More Related