-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Entity history - Logical delete design pattern ??
PostPosted: Thu Oct 09, 2003 2:14 am 
Newbie

Joined: Wed Oct 08, 2003 7:42 pm
Posts: 18
I am looking for a way to track an entity after removal. I am sure that this is a common situation. A couple of ways that we are considering are logical deletes or history tables.

The Customer/Order/Product situation (http://www.hibernate.org/hib_docs/refer ... xamples-s2)
would encounter this problem. What if you wanted to delete Customer or LineItem that was present in an Order but needed to keep the Order (and its Customer and Lineitem information) for history/reporting purposes.

Is there any pattern or solution to this problem?


The only information I could find was the following, but it only seems to handle part of the problem.

[color=blue]... "neat feature: class level WHERE. This allows for example implementing logical delete (delete using a flag) by having hibernate append


Top
 Profile  
 
 Post subject: Reversable Deletes
PostPosted: Thu Oct 09, 2003 11:50 am 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
Hi,

I'm not sure this is helpful, but I have tried to solve the problem of reversible deletes, or tiered deletes where sometimes you can only flag an entity as deleted, without removing it from the db, and sometimes you can actually delete it from the db. I created an interface for such classes of entities so that the process of deleting them could be unified for the entire app. Here's the code:

Code:
/**
* An interface that <code>Entity</code>s may adopt if the process of deleting them is controlled in the
* following way:
* <ol>
* <li>At some point in its lifecycle it may be deleted permanently.  This condition depends on the state
* of the entity and the other objects that the entity can navigate to.
* <li>At some point in its lifecycle it may only be deleted temporarily by setting a flag in the data
* source that marks it as deleted.  Again, this condition depends on the state of the entity and the other
* objects that the entity can navigate to.
* <li>(optionally) At some point in its lifecycle the entity cannot be deleted in any way.
* </ol>
*
* @author Jesse Costello-Good
* @version $Id: TieredDeleteEntity.java,v 1.5 2003/08/06 15:51:16 jesse Exp $
*/
public interface TieredDeleteEntity extends Entity {

   /**
    * Transformer that will filter out all the not hide deleted entities from a collection of
    * <code>TieredDeleteEntity</code>s.
    */
   public static final ListFilter IS_DELETED_FILTER = new ListFilter() {
      public boolean in( Object o ) {
         return ((TieredDeleteEntity) o).isHideDeleted();
      }
   };

   /**
    * Transformer that will filter out all the hide deleted entities from a collection of
    * <code>TieredDeleteEntity</code>s.
    */
   public static final ListFilter NOT_DELETED_FILTER = new InverseListFilter(IS_DELETED_FILTER);

   /**
    * Whether the entity may be deleted permanently by erasing it from the data source at this time.
    */
   public boolean mayEraseDelete();

   /**
    * Whether the entity may be deleted temporarily by hiding it at this time.
    */
   public boolean mayHideDelete();

   /**
    * Whether the entity is currently deleted temporarily (and may be undeleted).
    */
   public boolean isHideDeleted();

   /**
    * Set whether the entity is deleted temporarily.
    */
   public void setHideDeleted(boolean hideDeleted);

   /**
    * Bean interface for whether this entity is in some way deletable.
    */
   public boolean isDeletable();
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.