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

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

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

    MDA/MDD/TDD/DDD/DDDDDDD
    posts - 536, comments - 111, trackbacks - 0, articles - 0
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    hibernate和jdbc事務統一控制

    Posted on 2009-12-11 00:14 leekiang 閱讀(1013) 評論(0)  編輯  收藏 所屬分類: hibernatejdbc、事務、并發
    “Hibernate與JDBC(iBATIS)??都使用 DataSourceTransactionManager 同樣可以保證事務
    原理就是保證了 connection 的唯一性。
    jdbc我是調spring的jdbcTemplate來操作,
    經過測試。在同一個數據源的情況下直接使用Hibernate的TxManager可以同步事務,問題解決。

    Rod Johnson的話:
    引用
    It is possible--and sometimes useful--to have coordinated transactions for both. Your JDBC transactions will be managed by the HibernateTransactionManager if you work with the same JDBC DataSource in the same transaction. That is, create the SessionFactory using Spring's SessionFactoryBean using the same DataSource that your JdbcTemplates use.

    The only issue to watch, of course, is that you may be invalidating your Hibernate cache by JDBC changes. Generally I find it best to use JDBC to update only tables that don't have Hibernate mappings.

    Juergen Hoeller的話:
    引用
    As Rod said, simply keep using HibernateTransactionManager, which auto-detects the DataSource used by Hibernate and seamlessly exposes Hibernate transactions as JDBC transactions for that DataSource. JDBC code that accesses the same DataSource via Spring will automatically participate in such transactions.

    Note that you must specify the DataSource for Hibernate via LocalSessionFactoryBean's "dataSource" property to allow HibernateTransactionManager to auto-detect it. Alternatively, you can explicitly pass the DataSource to HibernateTransactionManager's "dataSource" property.
    http://www.fireflow.org/redirect.php?tid=498

    Rod Johnson在spring 論壇中有一句話很好的總結了如何在測試中處理hibernate緩存:
    Remember that you can clear the Hibernate session, removing objects already associated with it. This is often necessary before requerying in tests, and solves most (if not all) problems.
    I typically use JDBC for verification. The pattern is
    - do Hibernate operation
    - flush Hibernate session
    - issue JDBC query to verify results
    That way I'm verifying what Hibernate did to the database in the same transaction.
    主站蜘蛛池模板: 最近2019中文字幕免费大全5| 日本特黄特色AAA大片免费| 日韩免费高清大片在线| 日韩亚洲欧洲在线com91tv| 中文在线免费不卡视频| 在线a亚洲v天堂网2019无码| 久久WWW免费人成—看片| 亚洲人成图片小说网站| 久久久精品免费视频| 在线免费观看亚洲| 国产人在线成免费视频| 亚洲日本VA午夜在线影院| 国产高清免费在线| 国产黄在线观看免费观看不卡 | 亚洲天堂电影在线观看| 韩国免费一级成人毛片| 亚洲精品乱码久久久久久蜜桃图片| 免费电视剧在线观看| 国产亚洲美女精品久久| 亚洲人成在线播放网站| 精品女同一区二区三区免费站| 日本亚洲免费无线码| 亚洲国产成人乱码精品女人久久久不卡 | 亚洲人av高清无码| 亚洲va中文字幕无码| 成人影片一区免费观看| 亚洲男人电影天堂| 免费看小12萝裸体视频国产| 国产99视频精品免费视频76| 亚洲狠狠综合久久| 天天摸天天碰成人免费视频| 一区在线免费观看| 亚洲网站在线播放| 亚洲AV成人精品日韩一区18p| 久久久久久AV无码免费网站 | 在线观看免费视频一区| 亚洲国产精品白丝在线观看| 免费少妇a级毛片| 精品无码无人网站免费视频| 朝桐光亚洲专区在线中文字幕 | 亚洲国产成人久久77|