问题描述:配置了多数据源,sql写在文件中,使用dao4mbss这dao来执行sql,结果返回null,但是拿控制台打印的sql到数据库中执行是有结果的?
单独使用dao4mbss..fetch()来执行也是没有问题的,为什么把sql写入文件中调用不行呢?
dataSource : {
factory : "$conf#make",
args : ["com.alibaba.druid.pool.DruidDataSource", "db."],
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
create : "init",
depose : 'close'
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"}],
fields : {
executor : {refer:"cacheExecutor"},
sqlManager : {refer:"sqlManager"}
}
},
dataSource4mbss : {
factory : "$conf#make",
args : ["com.alibaba.druid.pool.DruidDataSource", "db4mbss."],
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
create : "init",
depose : 'close'
}
},
dao4mbss : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource4mbss"}],
fields : {
sqlManager : {refer:"sqlManager"}
}
},
//sql文件位置声明
sqlManager : {
type : "org.nutz.dao.impl.FileSqlManager",
args : ["sql/"]
},
注入
@Inject
protected Dao dao;
@Inject
protected Dao dao4mbss;
...
使用:
Sql sql = dao4mbss.sqls().create("getCrdInfoByCrdNo");
sql.setParam("crdNo", crdNo);
Record crdInfo = dao4mbss.execute(sql).getObject(Record.class);