<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 閱讀(1020) 評論(0)  編輯  收藏 所屬分類: hibernate 、jdbc、事務、并發
    “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.
    主站蜘蛛池模板: 国产亚洲精品国看不卡| 亚洲国产精品VA在线观看麻豆| 日韩人妻无码免费视频一区二区三区 | 4338×亚洲全国最大色成网站| 亚洲国产精品无码久久一线| 久久一区二区三区免费| 九九精品免费视频| 亚洲午夜国产精品无码 | 亚洲经典千人经典日产| 光棍天堂免费手机观看在线观看| 国产美女在线精品免费观看| 亚洲精品无码久久千人斩| 亚洲国产精品成人午夜在线观看| 处破痛哭A√18成年片免费| 亚洲Av无码精品色午夜| 丁香六月婷婷精品免费观看| 免费看国产精品3a黄的视频| 在线aⅴ亚洲中文字幕| 亚洲视频免费一区| 亚洲av永久无码精品漫画| 免费在线看黄网站| 成人AV免费网址在线观看| 亚洲电影一区二区三区| www免费黄色网| 亚洲国产91精品无码专区| 亚洲国产精品无码中文lv| 波多野结衣中文一区二区免费| 亚洲日日做天天做日日谢| 182tv免费观看在线视频| 亚洲高清视频在线| 亚洲精品国产日韩无码AV永久免费网| 亚洲AV电影天堂男人的天堂| 毛片A级毛片免费播放| 国产v亚洲v天堂a无| 男女做羞羞的事视频免费观看无遮挡| 亚洲精品亚洲人成在线| 午夜爱爱免费视频| 中文字幕视频免费在线观看| 久久久久久久综合日本亚洲| 色片在线免费观看| 亚洲中文字幕久久精品无码A|