title: What exactly is "persistence ignorance"?
body: <p>Persistence ignorance is typically defined as the ability to persist &amp; retrieve standard .NET objects (or POCOs if you really insist on giving them a name). And a <a href="http://msdn.microsoft.com/en-us/magazine/dd882510.aspx#id0420021" rel="noreferrer">seemingly well accepted definition of a standard .NET object</a> is:</p>
  
  <blockquote>
    <p>"...ordinary classes where you focus on the business problem at hand without adding stuff for infrastructure-related reasons..."</p>
  </blockquote>
  
  <p>However, I see people describing NHibernate as a framework that allows persistence ignorance, and yet it is a framework that cannot work on <em>any</em> standard .NET object, only standard .NET objects that adhere to particular design requirements, for example (<a href="https://www.hibernate.org/hib_docs/nhibernate/html/persistent-classes.html" rel="noreferrer">source</a>):</p>
  
  <ul>
  <li>All classes <em>must</em> have a default constructor</li>
  <li>Some features don't work unless classes are unsealed and all members are virtual</li>
  <li>Object identity doesn't work properly unless you abuse Equals/GetHashCode</li>
  </ul>
  
  <blockquote>
    <p><em>(Aside: Before anybody gets upset, I don't mean to pick on NHibernate here, it's just a frequently quoted example of a framework that supposedly permits persistence ignorance. I'm sure similar arguments could be applied to other ORMs that claim the same.)</em></p>
  </blockquote>
  
  <p>Now although the class in itself does not have any persistence-framework-specific attributes or base classes etc., to me it is not really "persistence ignorant" because it must follow a set of design guidelines to <em>facilitate</em> use by the chosen persistence framework. You must design and implement the class with the requirements of the persistence framework in mind; if you are ignorant of it the class may not work with it.</p>
  
  <p>Where I'm having trouble with the definition of "persistence ignorance"/"POCO" is that I don't see how, conceptually, this is really any different to adding attributes such as <code>[Serializable]</code> or <code>[DataContract]</code> or <code>[XmlType]</code> or any other persistence-framework-specific annotations that <em>facilitate</em> the persistence and retrieval of the entity using that framework.</p>
  
  <p>So, what exactly is "persistence ignorance"? </p>
  
  <p>Clearly the definition of it as being able to persist "ordinary classes" is a fallacy because the NHibernate ones are only ordinary insofar as not referencing framework-specific classes, whereas they are extraordinary inasmuch as they require unusual design choices such as default constructors and all-virtual members and Equals/GetHashCode implementations on mutable types.</p>
  
  <p>Is it therefore reasonable to say that "persistence ignorance" is true when objects facilitate the use of a persistence framework (either in design and structure or by use of framework-specific annotations) but do not perform any persistence logic themselves?</p>