-->
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: AssertionFailure: dirty, but no dirty properties
PostPosted: Thu Apr 14, 2005 8:43 am 
Newbie

Joined: Thu Apr 14, 2005 7:52 am
Posts: 1
Hi,

We're using Hibernate 3 (final) with an Interceptor that adds createdBy and created (when creating) and changedBy and changed (when updating).

In one case we are getting:

Code:
<2005-apr-14 kl 13:39 CEST> <Error> <Pan> <000000> <AssertionFailure.<init> : an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: dirty, but no dirty properties
        at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:157)
        at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
        at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:675)
        ....


I dont know why this is happening, and I'm a newbie to Hibernate... but I pinpointed the error to the
org.hibernate.event.def.DefaultFlushEntityEventListener class and the dirtyCheck method.

It seems that the flag that indicates that a dirty collection exists is never set? So I added the following code:
Code:
....
        event.setDirtyProperties(dirtyProperties);
      // Added:
      if(dirtyProperties != null && dirtyProperties.length > 0) {
            event.setHasDirtyCollection(true);
        }
        // /Added
      event.setDirtyCheckHandledByInterceptor(interceptorHandledDirtyCheck);
      event.setDirtyCheckPossible(!cannotDirtyCheck);
      ...


And that fix works for me... But I'm unsure if it's really needed?

Regards,
Lennart


Top
 Profile  
 
 Post subject: Cause of the assertion failure in my software
PostPosted: Mon Mar 27, 2006 8:54 am 
Newbie

Joined: Tue Oct 12, 2004 10:32 pm
Posts: 5
I was seeing the same assertion failure in my software, and I found the cause:

In the object I was trying to persist, my getter was returning a constant for the "modifiedBy" property:

Code:
public String getModifiedBy() {
  return "foo";
}


But I didn't realize I had an Interceptor that was setting the same property:

Code:
public class MyInterceptor extends EmptyInterceptor {
  public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
    boolean result = false;

    for (int i = 0; i < propertyNames.length; i++) {
      if (propertyNames[i].equals("modifiedBy")) {
        currentState[i] = "bar";
        result = true;
      }
    }

    return result;
  }
}


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.