自定义的EntityMaker在1.5.51版本里要怎么实现使用呢,官方的pdf文档介绍的太少了
public class AnDao extends NutDao{
protected EntityMaker createEntityMaker() {
return new MyEntityMaker();
}
public AnDao(){}
public AnDao(DataSource ds){
this();
this.setDataSource(ds);
}
}
public class Executor {
public static void main(String[] args) {
Dao dao = new AnDao(DataSourceUtil.getDataSource());
CMargintest p = new CMargintest();
p.setAge(22);
dao.insert(p);
}
}
这个是我自己实现了一个EntityMaker然后调用,结果报错了
错误信息:
Exception in thread "main" java.lang.NullPointerException
at com.ht.core.nutz.dao.MyEntityMaker.make(MyEntityMaker.java:92)
at org.nutz.dao.impl.EntityHolder.getEntity(EntityHolder.java:69)
at org.nutz.dao.impl.EntityHolder.getEntityBy(EntityHolder.java:186)
at org.nutz.dao.impl.NutDao._optBy(NutDao.java:919)
at org.nutz.dao.impl.NutDao.insert(NutDao.java:136)
at com.ht.dao.test.Executor.main(Executor.java:11)
原因就是
if (null != expert.getConf()) {
这个语句报错,expert为null,我这自己写的entitymaker是改了下系统默认的maker,就是改了下表名,字段名的解析规则,加一些字段注解而已