Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Basically... the problem in here is not sql related, at least not directly.
The mappings, the selects, the update, all work.
The problem is with the delete, i have an action event triggering a delete event(in a jtable in this case), when the action is triggered the first time, hibernate does the error that is below. But on the second try it goes fine, and so does the 3rd, etc.
Moreover, if i call twice the delete in the actionevent, it doesnt work.
The action event has to be called twice for it to work....
Here's what the action event looks like:
public void actionPerformed(ActionEvent e) {
if ("commit".equals(e.getActionCommand())) {
System.out.println("Committing data");
deleteLines();
}
}
and deleteLines:
private void deleteLines() {
for (int j =0; j<currentDeletedList.size();j++) {
Line toDelete = (Line) currentDeletedList.get(j);
Utils.deleteO(toDelete);
}
}
and deleteO:
public static void deleteO(Object toDelete) {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.delete(toDelete);
tx.commit();
}
Hibernate version:
3.0.5
Mapping documents:
N/A
Code between sessionFactory.openSession() and session.close():
a few sql requests(that work fine)
Full stack trace of any exception that occurs:
Exception in thread "AWT-EventQueue-0" org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [HiberFacture.Line#6]
at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:742)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:166)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:154)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:771)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:895)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascade(Cascades.java:847)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:112)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:59)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at HiberFac.Utils.deleteL(Utils.java:184)
at HiberFac.FacViewer.actionPerformed(FacViewer.java:232)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Name and version of the database you are using:
oracle 10
The generated SQL (show_sql=true):
N/A
Debug level Hibernate log excerpt:
N/A