配置:
dao : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"}],
fields : {
executor : {refer:"cacheExecutor"}
}
},
cacheExecutor : {
type : "org.nutz.plugins.cache.dao.CachedNutDaoExecutor",
fields : {
cacheProvider : {refer:"cacheProvider"},
cachedTableNames : ["sys_user", "sys_role", "sys_menu"],
enableWhenTrans : false, // 事务作用域内不启用缓存,默认也是false
db : "ORACLE"
}
},
日志:
[DEBUG] 2020-03-09 19:24:09,893 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM sys_role WHERE code=?) T WHERE ROWNUM <= 1) WHERE RN > 0
| 1 |
|----------|
| sysadmin |
For example:> "SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM sys_role WHERE code='sysadmin') T WHERE ROWNUM <= 1) WHERE RN > 0 "
[DEBUG] 2020-03-09 19:24:09,897 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:148) - sql = SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM sys_role WHERE code=?) T WHERE ROWNUM <= 1) WHERE RN > 0 , tables = []
[DEBUG] 2020-03-09 19:24:09,897 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:178) - not good for cache >> SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM sys_role WHERE code=?) T WHERE ROWNUM <= 1) WHERE RN > 0
[DEBUG] 2020-03-09 19:24:09,936 com.js.collection.web.commons.processor.LogTimeProcessor.process(LogTimeProcessor.java:26) - [GET ]URI=/tenant/test/get 74ms
[DEBUG] 2020-03-09 19:24:48,002 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:101) - Found mapping for [GET] path=/tenant/test/get : TenantTestController.get(TenantTestController.java:22)
[DEBUG] 2020-03-09 19:24:48,002 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'tenantTestController'<class com.js.collection.web.modules.controllers.tenant.user.TenantTestController>
[DEBUG] 2020-03-09 19:24:48,003 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM sys_role WHERE code=?) T WHERE ROWNUM <= 1) WHERE RN > 0
| 1 |
|----------|
| sysadmin |
For example:> "SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM sys_role WHERE code='sysadmin') T WHERE ROWNUM <= 1) WHERE RN > 0 "
[DEBUG] 2020-03-09 19:24:48,004 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:148) - sql = SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM sys_role WHERE code=?) T WHERE ROWNUM <= 1) WHERE RN > 0 , tables = []
[DEBUG] 2020-03-09 19:24:48,005 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:178) - not good for cache >> SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM sys_role WHERE code=?) T WHERE ROWNUM <= 1) WHERE RN > 0
[DEBUG] 2020-03-09 19:24:48,021 com.js.collection.web.commons.processor.LogTimeProcessor.process(LogTimeProcessor.java:26) - [GET ]URI=/tenant/test/get 19ms
写法:
dao.fetch("sys_role",Cnd.where("code","=","sysadmin"));
各位大神求理