Hi,
I'm trying to intercept the changes to the database with Interceptor and write some data about these changes into the DB.
The problem is that when I try to update the ObjectA into the DB the interceptor intercept the request and insert some data into the DB, but when this information is written the interceptor is called again for the ObjectA, and the program goes into a loop...
I guess this happens because the ObjectA is flushed again, and the interceptor is called everytime something uses the DB.
Is that correct?
What should I do?
Thanks.
Some code of mine:
public boolean onFlushDirty(
Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types )
{
try
{
RegistroHistorico regHist = this.carregaRegistroHistorico(
entity, LogHistoricoInterceptor.OPERACAO_UPDATE);
fac.writeLogAtualizacao(regHist);
}catch(Exception err)
{
err.printStackTrace();
}
return false;
}
public boolean onSave(
Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types )
{
try
{
if (! (entity instanceof RegistroHistorico))
{
RegistroHistorico regHist = this.carregaRegistroHistorico(entity, LogHistoricoInterceptor.OPERACAO_INSERT);
fac.writeLogAtualizacao(regHist);
}
}catch(Exception err)
{
err.printStackTrace();
}
return false;
}
_________________ Ricardo K. Costa
|