title: Global Filtering Across Entities
body: <p>All of my entities contain an <code>isDeleted</code> property since we've implemented a "soft delete" on all of our data. I am looking to apply a global filter to the entity so that no matter how it's called, records makred as <code>isDelete = 0</code> are the only ones returned.</p>
  
  <p>An example of my Business entity:</p>
  
  <pre><code>component persistent="true" table="hier_Businesses" extends="models.BaseEntity" {
      property name="businessID" fieldType="id" generator="increment";
      property name="business" notnull="true";
      property name="businessName" notnull="true";
      property name="isDeleted" ormtype="boolean" default="false";
      property name="businessDisplay" formula="concat(business, ' - ', businessName)";
      property name="centers" singularname="center" fieldtype="one-to-many" cfc="Center" fkcolumn="businessID" inverse="true" where="isDeleted = 0";
  
      // validation constraints
      this.constraints = {
          business = {validation = "required,max_length[5]", label = "Business"},
          businessName = {validation = "required,max_length[150]", label = "Business Name"}
      };
  
      public string function getFullBusinessName() {
          return getValue('businessName', '') &amp; ' (' &amp; getValue('business', '') &amp; ')';
      }
  }
  </code></pre>
  
  <p>As you can see, on the <code>centers</code> property there is <code>where="isDeleted = 0"</code> so that when calling Business.getCenters(), only the active items are returned. This works great for cases where a call to <code>getCenters()</code> is made (see <a href="https://stackoverflow.com/questions/6301745/conditions-for-accessors-in-coldfusion-orm">conditions for accessors in Coldfusion ORM</a>). However, if querying using HQL such as with <strong>ORMExecuteQuery</strong>, I will need to re-apply those conditions to the joins.</p>
  
  <p>I have also looked at examples of using <code>ORMGetSession().createFilter(...)</code>, but the implementation of that doesn't appear to create a global filter on an entity. Some documentation shows modifying the Hibernate mapping XML file, but that's a resource I do not have access to.</p>
  
  <p>Any other suggestions on how this can be obtained?</p>