When I set hibernate to use Interceptor or EventListener in my application, some exceptions start to be thrown in flush time.
Ex.
The folow code:
Code:
System.out.println("before");
//load the object
Vinculo v = sistema.getRecursosHumanos().consultarVinculo(200201129);
//change atributte
v.setAtivo(true);
//flush session
gerenciadorConexoes.getSessaoCorrente().flush();
System.out.println("after");
With the EventListener:
Code:
public class HibernateOnFlushEventListener implements FlushEntityEventListener {
public void onFlushEntity(FlushEntityEvent event)
throws HibernateException {
System.out.println("Tipo dirty: "+event.getEntity().getClass().getSimpleName());
}
}
the output is:
Code:
before
Tipo dirty: InstituicaoEnsino
Tipo dirty: TipoInstituicaoEnsino
Tipo dirty: VinculoImpl
siga.fachada.SistemaException: Don't dereference a collection with cascade="all-delete-orphan": siga.recursosHumanos.vinculo.Vinculo.vinculoPerfilCollection
at siga.bd.Controlador.cancelarTransacao(Controlador.java:146)
at siga.bd.Controlador.confirmarTransacao(Controlador.java:125)
at siga.fachada.ControladorRecursosHumanos.consultarVinculo(ControladorRecursosHumanos.java:4251)
at siga.Teste.main(Teste.java:62)
whithout the EventListener:
Code:
before
after
What could I'm doing wrong?