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

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

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

    cuiyi's blog(崔毅 crazycy)

    記錄點滴 鑒往事之得失 以資于發展
    數據加載中……

    Transaction續一

    (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) 評論(0)  編輯  收藏 所屬分類: JavaEE技術

    主站蜘蛛池模板: 免费国产a国产片高清| 亚洲一区二区三区在线播放| 亚洲精品无码久久| 亚洲精品视频免费在线观看| 最近中文字幕免费完整| 亚洲人成影院在线观看| 中国一级特黄高清免费的大片中国一级黄色片 | 亚洲视频.com| 日韩免费无砖专区2020狼| 国产专区一va亚洲v天堂| 四虎成人精品永久免费AV| 国产亚洲精品自在久久| 国产精彩免费视频| 亚洲国产精品久久人人爱| 三根一起会坏掉的好痛免费三级全黄的视频在线观看 | 亚洲邪恶天堂影院在线观看| 四虎影视免费在线| 毛片免费在线观看| 国产成人精品亚洲一区| 国产卡一卡二卡三免费入口| 亚洲一卡2卡4卡5卡6卡残暴在线| 精品剧情v国产在免费线观看| 黄色网站软件app在线观看免费| 亚洲午夜福利精品久久| 色影音免费色资源| 成人网站免费大全日韩国产| 亚洲人成电影网站久久| 97无码免费人妻超级碰碰碰碰| eeuss影院免费92242部| 国产午夜亚洲精品午夜鲁丝片| 在线观看H网址免费入口| 黄床大片免费30分钟国产精品| 国产精品亚洲综合久久| 亚洲av无码成人黄网站在线观看| 国内精品免费视频精选在线观看 | 国产成人高清亚洲一区久久 | 久久国产亚洲电影天堂| 午夜爽爽爽男女免费观看影院| 噜噜噜亚洲色成人网站| 亚洲欧洲另类春色校园网站| 亚洲AV日韩AV天堂一区二区三区|