Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
at java.util.HashMap$ValueIterator.next(HashMap.java:817)
at org.hibernate.util.LazyIterator.next(LazyIterator.java:55)
at br.com.murah.murahFramework.model.persistencia.hibernate.MurahBeanInterceptor.postFlush(MurahBeanInterceptor.java:52)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:347)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
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:585)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292)
at $Proxy0.flush(Unknown Source)
at br.com.murah.murahFramework.model.persistencia.hibernate.HibernateDAO.finalizarTransacao(HibernateDAO.java:1042)
at gerador.TesteCipher.main(TesteCipher.java:133)
Name and version of the database you are using: Oracle 10g XE
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hello,
I'm using an Interceptor implementation of the methods preFlush/postFlush to get the objects and to decode/enconde their attributes after/before to be saved on database.
But I'm getting the java.util.ConcurrentModificationException. There is any idea in how to fix this?
These methods are the best place to to this?
Thanks in advance for the help,
Eudenia
Code:
public class MurahBeanInterceptor extends EmptyInterceptor
{
public void preFlush(Iterator entities) throws CallbackException
{
try
{ if(entities==null)
return;
while(entities.hasNext()){
MurahBean bean=(MurahBean) entities.next();
if(bean!=null &&){
CodeHelper.encode(bean);
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new CallbackException("PreFlush problems... \n"+e.getMessage());
}
}
public void postFlush(Iterator entities) throws CallbackException{
try
{
if(entities==null)
return;
while( entities.hasNext()){
MurahBean bean=(MurahBean) entities.next();
if(bean!=null ){
CodeHelper.decode(bean);
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new CallbackException("PostFlush problems... \n"+e.getMessage());
}
}