1 / 18

Achieving Persistence Ignorance with NHibernate

Achieving Persistence Ignorance with NHibernate. James Kovacs JamesKovacs.com jkovacs@post.harvard.edu. What is Persistence Ignorance?. POCO – Plain Old CLR Object No persistence-related code Only business logic public class Customer {      public string Name { get; }

chico
Télécharger la présentation

Achieving Persistence Ignorance with 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. Achieving Persistence Ignorancewith NHibernate James Kovacs JamesKovacs.com jkovacs@post.harvard.edu

  2. What is Persistence Ignorance? • POCO – Plain Old CLR Object • No persistence-related code • Only business logic public class Customer {      public string Name { get; }     public Location Address { get; }     public IList<Order> Orders { get; }     public void AddOrder(Order o) {} }

  3. Why is Persistence Ignorance Important? • Separation of concerns • Single responsibility • Loose coupling • Testability • Re-use

  4. NHibernate and PI • No special persistence-related base class • No marker or callback interfaces • No persistence-related attributes • NHibernate domain class: public class Customer {      public string Name { get; }     public Location Address { get; }     public IList<Order> Orders { get; }     public void AddOrder(Order o) {} }

  5. NHibernate API

  6. Key Features for PI • Persistence by reachability • Automatic dirty checking • Transparent lazy loading

  7. Resources • NHibernate (http://www.nhibernate.org) • NHForge (http://www.nhforge.org) • NHibernate Resources (http://www.hibernate.org/365.html) • NHUsers Google Group (http://groups.google.com/group/nhusers) • ActiveWriter (http://using.castleproject.org/display/Contrib/ActiveWriter) • The Bookshelf (http://www.jameskovacs.com/blog/TheBookshelf.aspx)

  8. Questions James Kovacs JamesKovacs.com jkovacs@post.harvard.edu

More Related