-->
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.  [ 1 post ] 
Author Message
 Post subject: Why check if object is updated before deleting it?
PostPosted: Thu Nov 17, 2005 10:42 am 
Newbie

Joined: Mon Apr 19, 2004 3:24 pm
Posts: 9
Hi,

Can someone tell me why DefaultFlushEntityEventListener checks to see if an object is updated before it deletes it? The comment of "ignoring collections unless versioned" seeeeems to indicate that hibernate might be checking to see if someone else has updated the object in the meantime (in which was we'd want the delete to fail).

The code Im looking at is:

Code:
   private boolean isUpdateNecessary(final FlushEntityEvent event, final boolean mightBeDirty) {
      final Status status = event.getEntityEntry().getStatus();
      if ( mightBeDirty || status==Status.DELETED ) {
         // compare to cached state (ignoring collections unless versioned)
         dirtyCheck(event);
         if ( isUpdateNecessary(event) ) {
            return true;
         }
         else {
            FieldInterceptor.clearDirty( event.getEntity() );
            return false;
         }
      }
      else {
         return hasDirtyCollections( event, event.getEntityEntry().getPersister(), status );
      }
   }


I'm no expert in hibernate, but it seems to me if an object is deleted - you don't want to update it... am I wrong?


Hibernate version:
3.1 rc2


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

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.