Hi..
I'm having a problem with onDelete method in Hibernate 2.1. My onDelete method needs to do a query with other entities, with cause an autoflush.
As a consequence of this, the parent entity is deleted before I can delete the child entities. The full stacktrace below.
The tables "recurso" and "agenda" are the parent entity (joined-subclass in this case). The onDelete method of Recurso is
Code:
(228) try {
(229) s.delete("select p from Permissao p where p.recurso = ?", this, Hibernate.entity(getClass()));
(230) } catch (HibernateException e) {
(231) throw new CallbackException(e);
(232) }
(233) return false;
Am I doing something wrong, or is this a bug?
Thanks,
Robson Paniago
21:11:49,385 INFO [STDOUT] Hibernate: delete from recurso where id=?
21:11:49,385 INFO [STDOUT] Hibernate: delete from agenda where id=?
21:11:49,385 WARN [JDBCExceptionReporter] SQL Error: 350, SQLState: 23000
21:11:49,385 ERROR [JDBCExceptionReporter] [350]: Referential integrity violated:FKB307E11599C04A2E,CAMPUS,EVENTO
21:11:49,385 ERROR [JDBCExceptionReporter] Could not synchronize database state with session
com.sap.dbtech.jdbc.exceptions.DatabaseException: [350]: Referential integrity violated:FKB307E11599C04A2E,CAMPUS,EVENTO
at com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:69)
at com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:763)
at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:429)
at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:320)
at com.sap.dbtech.jdbc.CallableStatementSapDB.execute(CallableStatementSapDB.java:380)
at com.sap.dbtech.jdbc.CallableStatementSapDB.execute(CallableStatementSapDB.java:289)
at com.sap.dbtech.jdbc.CallableStatementSapDB.executeUpdate(CallableStatementSapDB.java:697)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:308)
at net.sf.hibernate.persister.NormalizedEntityPersister.delete(NormalizedEntityPersister.java:606)
at net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.java:22)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2100)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2066)
at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1566)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1372)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1332)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1457)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1447)
at unb.campusvirtual.ejb.dataobjects.Recurso.onDelete(Recurso.java:229)
at unb.campusvirtual.ejb.dataobjects.Agenda.onDelete(Agenda.java:54)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:977)
at unb.campusvirtual.ejb.impl.ControleGerenciamentoRecursosBean.excluiRecurso(ControleGerenciamentoRecursosBean.java:189)
....
Code:
Code: