Default style (Cherry Eve). Switch styles (Capricorn). XML Feed Calendar
全部分类 | CAPS | family | General | Java | sourceforge
20040703 星期六 2004年07月03日

Never use hibernate JTATransaction implemention because it's wrong

Commonly, JTATransaction shall be used as the following:
      Lookup UserTransaction and begin transaction
      get Connection from DS and do something and close the connection
      get Connection from DS and do something and close the connection
      ...
      commit or roolback
 
So, you can see only the connection as opened after jtaTransaction started will be managed by the Transaction.
 
But In Hibernate, The Transaction is new by a parameter Session.
      JTATransaction(SessionImplementor session)
You can see the JTATransaction is based on the session.
So if the session has already connected, the connection can't been managed by the transaction.
So it is realy realy wrong.
 
The right flow to use JTATransaction through hibernate shall like the following:
     Lookup UserTransaction and begin transaction
     get hibernate session and do something and flush
     ...
     commit or rollback
 
 
So the better way is use cmt SessionBean.

七月 03, 2004 01:06 上午 GMT+08:00 Permalink

评论:

发表一条评论:

该日志评论功能被禁用了。