<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    cuiyi's blog(崔毅 crazycy)

    記錄點(diǎn)滴 鑒往事之得失 以資于發(fā)展
    數(shù)據(jù)加載中……

    Transaction續(xù)一

    (Resent)  The mail topic "share some knowledge based on Felcra project"

    1) About transaction

        Inside transaction logic:

        Never use:  try{}catch(Exception e) {e.printStackTrace();};

        Never use:  try{}catch(Exception e) {};

        Never use:  try{}catch(Exception e) {log.....};


        but     use:  try{

                              //biz logic

                           } catch(Exception e) {

                             //can print //can log

                             throw e; //very very important 

                           };

     

          Spring can define the rollback transaction exception type, but if the defined exception is not thrown from the catch-block, the whole transaction will not be rolled back. This point is very very important.

          

     2) About Error thrown.

        Try not to do biz logic at the catch-block, except throws exception directly.

        But sometime need to write log or db, which is special case.

      

        Do less thing at the catch-block, especially never include any business logic.

        If some biz logic is necessary, try to think use Boolean-Return or State-Pattern or Object-Return to replace.

        The reason? Because biz logic in catch-block will cost a lot of JVM resource and it will also cause performance problem, this is traps in JAVA.

     

     

    (Resent)  The mail topic "knowledage for ost-dao-config.xml"

    3) About ost-dao-config.xml.

    There are 2 interceptors inside "ost-dao-config.xml", which is quite different from SD FFB Book. 

     

    SD FFB only use Hibernate, whose scope includes "*Service" "HibernateDao"

    FC Raw use both Hibernate, Spring JDBC, also JMS.

     

    If only Hibernate, OpenSessionInView Pattern will manage the transaction, which should transacted SessionFactory. 

     

    If not only Hiberante, SessionFactory which is transaction-wrapped can only manage Hibernate. Spring JDBC/JMS is out of the SessionFactory scope.

     

    Now come to explain the 2 interceptors:

    1) transactionInterceptor:  It manages beans with name: <value>*dbcTemplate,*Service,*Sender,mhlImportBean</value>. It manages all except Hibernate-related.

    2) hibernateInterceptor: It manages bean: sessionFactory, which will transaction-wrapped Hiberante-related. If hibernateInterceptor is not configured, the evil thing will happen: HibernateDao will write into DB while error thrown in *Service.

     

    4) How does the 2 methods in Hibernate get data?

        HibernateDao.getObject(), which used a lot in FC Raw/SD FFB Book.

        In fact, it uses Spring HibernateTemplate.get(); which will get data from Hibernate 1st-level cache first, if get, then return; Otherwise, get from Database.

         Another one is Criteria.list(); The method will get data from database as queried.

      

    5) HibernateDao.flush()

        It is out-of any transaction-rollback scope. Should Never or less use.

     

    posted on 2010-09-06 20:44 crazycy 閱讀(515) 評(píng)論(0)  編輯  收藏 所屬分類: JavaEE技術(shù)

    主站蜘蛛池模板: 成年大片免费视频| 久久久久久AV无码免费网站下载| 99热在线精品免费全部my| 亚洲电影中文字幕| 日本xxxx色视频在线观看免费| 亚洲中文字幕无码日韩| 中文字幕免费播放| 久久精品国产精品亚洲下载| jyzzjyzz国产免费观看| 久久亚洲国产成人精品无码区| 久青草视频97国内免费影视| 日韩一卡2卡3卡4卡新区亚洲| 久久WWW免费人成—看片| 在线精品亚洲一区二区三区| 成全视频高清免费观看电视剧| 亚洲欧洲在线观看| 久久久久久久免费视频| 亚洲丁香婷婷综合久久| 亚洲精品视频在线看| 三年在线观看免费观看完整版中文| 久久精品国产亚洲av麻| 免费v片在线观看视频网站| 亚洲综合色一区二区三区| 四虎永久在线精品免费影视| h在线看免费视频网站男男| 亚洲爱情岛论坛永久| 歪歪漫画在线观看官网免费阅读 | 久久久久亚洲AV无码永不| 精品国产sm捆绑最大网免费站| 一本色道久久88—综合亚洲精品 | 一级成人a免费视频| 亚洲AV无码国产丝袜在线观看 | 国产成人免费午夜在线观看 | a毛片全部免费播放| 亚洲精品国产免费| 国产在线观看免费视频播放器| 中文字幕成人免费高清在线视频 | 免费又黄又爽又猛大片午夜| 亚洲高清在线观看| 免费观看大片毛片| 亚洲精品免费在线观看|