2011-04-30 66 views
3

過去幾天我一直在玩ORM緩存,有一件事讓我很困惑,即使啓用了緩存,SQL仍會記錄(當我有logSQL = true時)到控制檯。這讓我認爲緩存不起作用,我認爲hibernate並沒有創建sql,因爲它看到緩存中的對象,但是也許hibernate在檢查ehcache之前生成sql。ColdFusion ORM緩存和LogSQL

我的代碼低於只是在有人拿起我錯過的東西。 的Application.cfc

this.ormSettings.secondarycacheenabled = "true"; 
this.ormSettings.cacheprovider="ehcache"; 
this.ormSettings.logSQL=true; 

然後我的書CFC

component persistent="true" entityname="Books" table="db_books" cacheuse="transactional" lazy="true" 

,最後的代碼即時通訊使用調用。

a = entityloadbypk("Books","1"); 
writeoutput(a.getName()); 

回答

2

從我讀過的和經驗豐富的第一手資料,轉移過線到你的DBMS的SQL將始終無論ColdFusion的ORM(休眠)是否產生它JIT,或從緩存中拉的記錄。如果有的話,你可以運行一些基準來快速確定緩存實際上是否被使用。