I have the followingmethod in my Session EJB:
public void updateTestMe() throws Exception{
try{
TestMe tm = new TestMe();
tm.setComments("just"); // name is PK .. and defined as uid.hex
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session sess = sf.openSession();
Transaction tx = sess.beginTransaction();
sess.save(tm);
tx.commit();
sess.close();
}
catch (Exception e){
e.printStackTrace();
}
}
The database table testme has 2 cols: NAME and COMMENTS. Name is inserted by Hibernate.
Questions:
(A) Insert is OK. But why do I see the this Exception (see below)
(B) Why is Hibernate printing: insert into abc.testme (COMMENTS, NAME) values (?, ?)
NAME should be the 1st column, not COMMENTS????
[8/19/04 16:03:27:149 CDT] 1214f92e SystemOut U Hibernate: insert into abc.testme (COMMENTS, NAME) values (?, ?)
java.lang.IllegalStateException: Illegal operation: tried to commit connection in global tran
at com.ibm.ejs.cm.pool.ConnectO.commit(ConnectO.java:2416)
at com.ibm.ejs.cm.proxy.ConnectionProxy.commit(ConnectionProxy.java:788)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:63)
at com.test.ejb.session.TestSessionEJBBean.updateTestMe(TestSessionEJBBean.java:167)
at com.test.ejb.session.EJSRemoteStatelessTestSessionEJB_25ca6f84.updateTestMe(EJSRemoteStatelessTestSessionEJB_25ca6f84.java:49)
at com.test.ejb.session._TestSessionEJB_Stub.updateTestMe(_TestSessionEJB_Stub.java:305)
at com.pioneer.test.delegates.TestBD.updateTestMe(TestBD.java:71)
at com.test.servlets.PartnersServlet.doPost(PartnersServlet.java:53)
at com.test.servlets.PartnersServlet.doGet(PartnersServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:721)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:374)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:118)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:134)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:239)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:151)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:317)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:391)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:274)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:144)
|