氟塑料離心泵www.buybeng.com

          jquery教程http://www.software8.co/wzjs/jquery/

          Hibernate JPA中insert插入數(shù)據(jù)后自動執(zhí)行select last_insert_id()解決方法

          本文出處:http://www.0769zzw.com/tec/channel-100/tec-3172.html,轉(zhuǎn)載請注明。由于本人不定期會整理相關(guān)博文,會對相應(yīng)內(nèi)容作出完善。因此強(qiáng)烈建議在原始出處查看此文。
          今天做項(xiàng)目遇到了一個(gè)問題,是以前沒注意的。我用的是Spring MVC+ Hibernate JPA + MySQL數(shù)據(jù)庫。在插入數(shù)據(jù)后SQL執(zhí)行日志中會多出一條select語句:
          Hibernate: insert into click_statstic (logDate, memoId, src, typeId) values (?, ?, ?, ?)  
          Hibernate: select last_insert_id()  
          表中有個(gè)主鍵是自增列。可是在以往的項(xiàng)目中,沒發(fā)現(xiàn)有這樣的問題。于是在網(wǎng)上各種找也找不到原因。心想可能是配置問題。
          最終在persistence.xml配置文件中找到了這樣一條配置:
          <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" />  
          把這條配置刪除就沒有了多余的select語句。具體原因和這樣做的目的是什么不得而知。如果有知道的朋友請分享下~多謝了。

          posted on 2013-03-07 19:13 你爸是李剛 閱讀(2800) 評論(1)  編輯  收藏

          評論

          # re: Hibernate JPA中insert插入數(shù)據(jù)后自動執(zhí)行select last_insert_id()解決方法[未登錄] 2013-03-12 10:45 Shine

          hibernate.temp.use_jdbc_metadata_defaults 默認(rèn)為 true
          這條配置開啟后 Hibernate在獲取connection之前,需要獲取相應(yīng)DB的META DATA信息,顧及下面的SQL就是與后面需要的META DATA有關(guān);
          下面是找到資料,僅供參考哈!:)


          // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
          // The need for it is intended to be alleviated with future development, thus it is not defined as an Environment constant...
          //
          // it is used to control whether we should consult the JDBC metadata to determine
          // certain Settings default values; it is useful to *not* do this when the database
          // may not be available (mainly in tools usage).

          boolean useJdbcMetadata = ConfigurationHelper.getBoolean( "hibernate.temp.use_jdbc_metadata_defaults", configValues, true );  回復(fù)  更多評論   


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          <2013年3月>
          242526272812
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          技術(shù)網(wǎng)站

          行業(yè)網(wǎng)站

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          站長網(wǎng) 氟塑料離心泵 注塑機(jī) 液晶廣告機(jī)
          主站蜘蛛池模板: 桑植县| 威远县| 清远市| 郯城县| 竹溪县| 融水| 新余市| 洛扎县| 扎赉特旗| 永顺县| 恭城| 岗巴县| 白河县| 磐安县| 苍山县| 大田县| 横峰县| 常山县| 泰兴市| 天台县| 南投县| 甘孜| 永仁县| 赤壁市| 西林县| 临邑县| 冀州市| 沙坪坝区| 龙江县| 合阳县| 高安市| 五峰| 周宁县| 会宁县| 蒙山县| 比如县| 西乡县| 昆明市| 景谷| 肇源县| 桐城市|