/* Sobreescribimos el metodo que elimina los profesionales */
public static void borrar(Long idSolicitud,Long idProfesionales){
checkAuthenticity();
if(!permiso("delete")){
Messages.error("No tiene permisos suficientes para
realizar la acción");
}
Profesionales dbProfesionales = null;
Solicitud solicitud = null;
if(!Messages.hasErrors()){
dbProfesionales = getProfesionales(idSolicitud,
idProfesionales);
solicitud = getSolicitud(idSolicitud);
}
if(!Messages.hasErrors()){
solicitud.profesionales.remove(dbProfesionales);
solicitud.save();
dbProfesionales.delete();
}
// A) - CÓDIGO QUE ELIMINE LA PARTICIPACIÓN DEL PROFESIONAL EN LA
SOLICITUD ACTUAL
Agente bond = Agente.find("select agente from Agente agente
where
agente.name=?", dbProfesionales.nombre).first();
System.out.println("antes de conseguir la participacion del
profesional "+
bond.id + " en la solicitud " + idSolicitud + ".");
Participacion p = Participacion.find ("select participacion
from Participacion participacion where
participacion.agente.id=? and
participacion.solicitud.id=?",
bond.id, idSolicitud).first();
if (p == null) System.out.println("no encuentra la
participacion");
else System.out.println("hemos conseguido la participacion: "
+ p.getId());
p.delete();
//System.out.println("hemos conseguido borrar la
participacion");
// B) - CÓDIGO QUE COMPRUEBE QUE YA EL PROFESIONAL NO TIENE
PARTICIPACIONES, Y LO BORRA COMO AGENTE
//bond.delete();
//System.out.println("Adios, señor Bond...");
/*
**************************************************************************************
*/
if(!Messages.hasErrors()){
renderJSON(utils.RestResponse.ok("Registro borrado
correctamente"));
} else{
Messages.keep();
abrir("borrar",idProfesionales,idSolicitud);
}
}
Internal Server Error (500) for request POST /
popups.pprofesionalcontroller/borrar
Execution exception (In /app/controllers/popups/
PProfesionalController.java around line 160)
PersistenceException occured :
org.hibernate.exception.ConstraintViolationException: Could not
execute JDBC batch update
play.exceptions.JavaExecutionException:
org.hibernate.exception.ConstraintViolationException: Could not
execute JDBC batch update
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at Invocation.HTTP Request(Play!)
Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.ConstraintViolationException: Could not
execute JDBC batch update
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1214)
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1147)
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:
1153)
at
org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:
798)
at play.db.jpa.JPABase._delete(JPABase.java:73)
at play.db.jpa.GenericModel.delete(GenericModel.java:219)
at
controllers.popups.PProfesionalController.borrar(PProfesionalController.java:
160)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:
546)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:
476)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:
471)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159)
... 1 more
Caused by: org.hibernate.exception.ConstraintViolationException: Could
not execute JDBC batch update
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:
96)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:
66)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
275)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:
114)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:
109)
at
org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:
244)
at
org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:
2666)
at
org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:
2911)
at
org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:
97)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:
265)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:
189)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:
345)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:
51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at
org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:
795)
... 9 more
Caused by: java.sql.BatchUpdateException: Cannot delete or update a
parent row: a foreign key constraint fails
(`bonostecnologicos`.`participacion`, CONSTRAINT `FKE59902D256F33620`
FOREIGN KEY (`solicitud_id`) REFERENCES `solicitud` (`id`))
at
com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:
2018)
at
com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:
1449)
at
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:
70)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
268)
... 22 more