As requested on the bug reporting page at hibernate.org, I'm trying to verify a probable bug I found in Hibernate. I'm using Hibernate (2.5.0, with annotations 3.3.0 and entitymanager 3.3.1) as a persistence provider in Glassfish. The database I'm using is PostgreSQL 8.2.4 with the current (JDBC3, b. 206) version of its JDBC driver.
I have a view defined taking all columns from one table, only choosing a subset of all the original table's rows. Then I have several rules defined on the view for updating and inserting data into it.
Each insert or update requires the database to make two inserts into two separate tables. Both rules have a condition consisting of a function doing a single select.
Performing an insert or update on the view works as expected, inserts the required data, although (I suppose because of the multiple operations done for a single insert) it returns that "0 rows have been affected".
When trying to do the same update through the application, using hibernate, I get a javax.transaction.RollbackException.
The Java code is fine, since all other entities work flawlessly and also if I switch the entity mapping the view to the original table (the one the view's columns are taken from) updates and inserts work well.
Last but not least, here's the exception's stack trace. What's weir about it is, that it contains absolutely no information about any error, just like the transaction's being rolled back without reason.
Code:
Exception in thread "AWT-EventQueue-2" javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:243)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:205)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
at pl.hefajstos.ejb.interf.__TradeMaterialControllerBeanInterface_Remote_DynamicStub.createTradeMaterial(pl/hefajstos/ejb/interf/__TradeMaterialControllerBeanInterface_Remote_DynamicStub.java)
at pl.hefajstos.ejb.interf._TradeMaterialControllerBeanInterface_Wrapper.createTradeMaterial(pl/hefajstos/ejb/interf/_TradeMaterialControllerBeanInterface_Wrapper.java)
at pl.hefajstos.bean.TradeMaterialBean.saveTradeMaterial(TradeMaterialBean.java:56)
at pl.hefajstos.gui.TradeMaterialFrame.saveTradeMaterial(TradeMaterialFrame.java:365)
at pl.hefajstos.gui.TradeMaterialFrame.saveButtonActionPerformed(TradeMaterialFrame.java:293)
at pl.hefajstos.gui.TradeMaterialFrame.access$100(TradeMaterialFrame.java:19)
at pl.hefajstos.gui.TradeMaterialFrame$2.actionPerformed(TradeMaterialFrame.java:231)
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.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.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(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)
Caused by: java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:251)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1386)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:210)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
at $Proxy35.createTradeMaterial(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:440)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:371)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
... 19 more
javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
at pl.hefajstos.ejb.interf._TradeMaterialControllerBeanInterface_Wrapper.createTradeMaterial(pl/hefajstos/ejb/interf/_TradeMaterialControllerBeanInterface_Wrapper.java)
at pl.hefajstos.bean.TradeMaterialBean.saveTradeMaterial(TradeMaterialBean.java:56)
at pl.hefajstos.gui.TradeMaterialFrame.saveTradeMaterial(TradeMaterialFrame.java:365)
at pl.hefajstos.gui.TradeMaterialFrame.saveButtonActionPerformed(TradeMaterialFrame.java:293)
at pl.hefajstos.gui.TradeMaterialFrame.access$100(TradeMaterialFrame.java:19)
at pl.hefajstos.gui.TradeMaterialFrame$2.actionPerformed(TradeMaterialFrame.java:231)
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.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.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(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)