-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Update SUCCESS but See Exception on Log
PostPosted: Thu Aug 19, 2004 5:09 pm 
Newbie

Joined: Thu Aug 19, 2004 9:05 am
Posts: 7
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)


Top
 Profile  
 
 Post subject: Hibernate UPDATE success but throws Exception
PostPosted: Thu Aug 19, 2004 10:05 pm 
Newbie

Joined: Thu Aug 19, 2004 9:05 am
Posts: 7
No reply?????


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 10:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
If you are using CMT, you don't really need to use the Hibernate Transaction API, just let WebSphere demarcate txns for you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 10:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Of course, you should certainly NOT be using JDBCTransaction with JTA, as per the doco.


Top
 Profile  
 
 Post subject: Update SUCCESS but See Exception on Log
PostPosted: Fri Aug 20, 2004 8:58 am 
Newbie

Joined: Thu Aug 19, 2004 9:05 am
Posts: 7
Thanks. I commented the code for Transaction in method.

TestMe tm = new TestMe();
tm.setComments("just ");
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session sess = sf.openSession();
//Transaction tx = sess.beginTransaction();
sess.save(tm);
//tx.commit();
sess.close();

But now I dont see any updates in DB.


Top
 Profile  
 
 Post subject: Update SUCCESS but See Exception on Log
PostPosted: Fri Aug 20, 2004 9:33 am 
Newbie

Joined: Thu Aug 19, 2004 9:05 am
Posts: 7
Yes, my session EJB is Stateless and uses Container managed transaction.

While I cannot see any updates if I disable transaction in Hibernate, the read operations are OK.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 10:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
flush() the session. this is a FAQ


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.