title: Logical delete at a common place in hibernate
body: <p>I am using Spring and Hibernate for my application. </p>
  
  <p>I am only allowing logical delete in my application where I need to set the field isActive=false. Instead of repeating the same field in all the entities, I created a Base Class with the property and getter-setter for 'isActive'.</p>
  
  <p>So, during delete, I invoke the update() method and set the isActive to false.</p>
  
  <p>I am not able to get this working. If any one has any idea, please let me know. </p>
  
  <p><strong>Base Entity</strong></p>
  
  <pre><code>public abstract class BaseEntity&lt;TId extends Serializable&gt; implements IEntity&lt;TId&gt; {
  
      @Basic
      @Column(name = "IsActive")
      protected boolean isActive;
  
      public Boolean getIsActive() {
          return isActive;
      }
  
      public void setIsActive(Boolean isActive) {
          isActive= isActive;
      }
  }
  </code></pre>
  
  <p><strong>Child Entity</strong></p>
  
  <pre><code>@Entity(name="Role")
  @Table(schema = "dbo")
  public class MyEntity extends BaseEntity {
      //remaining entities
  }
  </code></pre>
  
  <p><strong>Hibernate Util Class</strong></p>
  
  <pre><code>public void remove(TEntity entity) {
  
      //Note: Enterprise data should be never removed.
      entity.setIsActive(false);
      sessionFactory.getCurrentSession().update(entity);
  }
  </code></pre>