I have a group of objects, each of which has a property 'createdSignature' mapped as a component. This class contains a user ID (String) and a date/time (Calendar).
I have an interceptor that traps onSave and onFlushDirty to set these values. Sometimes, but not always, I get an error 'dirty, but no dirty properties'.
For these tests with intermitent errors, I am calling merge, passing it a new object A, which has a 1-M bag containing a single new B.
This problem did not appear before adding an interceptor. The interceptor code is:
Code:
public class AuditInterceptor extends EmptyInterceptor {
public boolean onFlushDirty(Object entity, Serializable id,
Object[] currentState, Object[] previousState,
String[] propertyNames, Type[] types) {
if (entity instanceof IAuditable) {
for (int i = 0; i < propertyNames.length; i++) {
if ("createdSignature".equals(propertyNames[i])) {
currentState[i] = createSignature();
return true;
}
}
}
return false;
}
public boolean onSave(Object entity, Serializable id, Object[] state,
String[] propertyNames, Type[] types) {
if (entity instanceof IAuditable) {
for (int i = 0; i < propertyNames.length; i++) {
if ("createdSignature".equals(propertyNames[i])) {
state[i] = createSignature();
return true;
}
}
}
return false;
}
private UserSignature createSignature() {
UserSignature signature = new UserSignature();
String assignID;
try {
assignID = SessionManager.getSession(
SecurityContext.getInstance().getSessionId())
.getMainAssignmentID();
} catch (NoSessionException ex) {
throw new HibernateException(ex);
}
signature.setAssignmentId(assignID);
signature.setDate(Calendar.getInstance());
return signature;
}
}
By the way, I found that the event that triggered the exception was a flush on the child (B) entity.
Any ideas?
Hibernate version: 3.1.1
Full stack trace of any exception that occurs:
2006-04-05 18:18:58,151 ERROR [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.scheduleUpdate(DefaultFlushEntityEventListener.java:249)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:114)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1007)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:354)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at ca.gc.csc_scc.model.impl.dao.hibernate.util.HibernateUtil.commitTransaction(HibernateUtil.java:127)
at ca.gc.csc_scc.model.impl.service.handler.TransactionHandler.invoke(TransactionHandler.java:47)
at $Proxy2.save(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at com.osmoticweb.gzipfilter.GZIP2WayFilter.doFilter(GZIP2WayFilter.java:54)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
Name and version of the database you are using: Oracle