I have a problem when persisting an object to a table with an identity column. I'm executing the save inside a local stateless session bean inside a container managed transaction. This is running in WAS (WebSphere) 5 against a Sybase database (v12) using the container's connection pool.
Here is the mapping file for the object:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="business.objects.BeneficiaryImpl" table="beneficiary">
<id name="id" type="long" column="id">
<generator class="native"/>
</id>
<property name="city" type="string" column="city"/>
<property name="countryCode" type="string" column="country_code"/>
<property name="description" type="string" column="description"/>
<property name="name" type="string" column="name"/>
<property name="state" type="string" column="state"/>
<property name="walletItemId" type="long" column="wallet_item_id"/>
</class>
</hibernate-mapping>
The (primary key) id column is an IDENTITY column in the table. When I flush the session, I get the following exception trace:
<trace>
[9/20/03 13:46:57:047 EDT] 257430f5 TableGenerato E net.sf.hibernate.id.TableGenerator could not read a hi value
[9/20/03 13:46:57:047 EDT] 257430f5 TableGenerato E net.sf.hibernate.id.TableGenerator TRAS0014I: The following exception was logged com.sybase.jdbc2.jdbc.SybSQLException: hibernate_unique_key not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2535)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1916)
at com.sybase.jdbc2.tds.Tds.getResultSetResult(Tds.java:2447)
at com.sybase.jdbc2.tds.TdsCursor.open(TdsCursor.java:189)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1425)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:70)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:498)
at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:599)
at americas.persistence.services.order.OrderPersistenceServiceBean.persistOrder(OrderPersistenceServiceBean.java:102)
at americas.persistence.services.order.EJSLocalStatelessOrderPersistenceService_789ebbc3.persistOrder(EJSLocalStatelessOrderPersistenceService_789ebbc3.java:43)
at americas.business.services.order.OrderServiceFactory$OrderServiceImpl.createOrder(OrderServiceFactory.java:194)
at americas.col.actions.OrderConfirmationAction.execute(OrderConfirmationAction.java:53)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
----- Begin backtrace for next
com.sybase.jdbc2.jdbc.SybSQLException: The cursor 'jconnect_implicit_1' can not be used as it could not be found. It is possible that either it was not declared or it is not available in the current context.
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2535)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1916)
at com.sybase.jdbc2.tds.Tds.getResultSetResult(Tds.java:2447)
at com.sybase.jdbc2.tds.TdsCursor.open(TdsCursor.java:189)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1425)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:70)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:498)
at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:599)
at americas.persistence.services.order.OrderPersistenceServiceBean.persistOrder(OrderPersistenceServiceBean.java:102)
at americas.persistence.services.order.EJSLocalStatelessOrderPersistenceService_789ebbc3.persistOrder(EJSLocalStatelessOrderPersistenceService_789ebbc3.java:43)
at americas.business.services.order.OrderServiceFactory$OrderServiceImpl.createOrder(OrderServiceFactory.java:194)
at americas.col.actions.OrderConfirmationAction.execute(OrderConfirmationAction.java:53)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
.
com.sybase.jdbc2.jdbc.SybSQLException: hibernate_unique_key not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
</trace>
The frustrating thing is that the mapping/code works in standalone (i.e., outside of the container with Hibernate pooling). It also works in a second application (J2EE running on WAS 5) already in production in the same way. The only difference between the two applications is that, prior to calling save for this object, I am saving several other objects with assigned ids instead of native ids within the transaction.
Any help or insight would be greatly appreciated.
BTW, congrats on the new job, Gavin ;-) Keep up the good work.[/code]
|