hibernate2 使用記錄

本人不太喜歡hibernate,遇見更低的版本自然是不爽,不爽歸不爽,工作中有用到它,自然得和它打交道了,此文記錄使用過程中遇見的問題
/****************************query接口出現N+1查詢問題 begin******************************/
此處涉及的N+1問題並不是兩表關聯導致,而是單表查詢是出現的例如select c from Test c 會執行select id from test,然後執行N條select * from test where id=?
查看iterate api 說明如下
Return the query results as an Iterator. If the query contains multiple results pre row, the results are returned in an instance ofObject[].
Entities returned as results are initialized on demand. The first SQL query returns identifiers only.
改用list 應該可以
/****************************query接口出現N+1查詢問題 end******************************/

/****************************hibernate2查詢版本信息 begin******************************/
net.sf.hibernate.cfg.Environment.VERSION
/****************************hibernate2查詢版本信息 end******************************/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章