在过去的几天里,我一直在玩 ORM 缓存,而让我很困惑的一件事是,即使启用了缓存,SQL 仍然被记录到控制台(当我有 logSQL = true 时)。这让我认为缓存不起作用,我认为hibernate不会创建sql,因为它会在缓存中看到对象,但也许hibernate甚至在检查ehcache之前就生成了sql。
我的代码在下面,以防有人捡到我错过的东西。应用程序.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());