NutzCN Logo
问答 bean里json字段是map类型,构造函数出错
发布于 2849天前 作者 qq_8c799e25 1662 次浏览 复制 上一个帖子 下一个帖子
标签:
@Table("t_index_5min_kline")
@PK(value = { "zqdm", "date" })
public class Index5minKline{
	@Column
	private String zqdm;
    
    @Column
	private int date;
    

    @Column
    @ColDefine(type=ColType.MYSQL_JSON)
    private Map<String, Index5minKlineItem> datas;

	public Index5minKline(){
		
	}
	
	public Index5minKline(String zqdm, int date, Map<String, Index5minKlineItem> datas, boolean done) {
		this();
		this.zqdm = zqdm;
		this.date = date;
		this.datas = datas;
		this.done = done;
	}
}

写数据库都ok,但从mysql读取的时候出错:
IndexDayKline last = dao.fetch(IndexDayKline.class, Cnd.where(TdxClient.KEY_ZQDM, "=", zqdm));

2017-03-04 20:47:29,802 INFO - Fail to value by setter
org.nutz.lang.born.BorningException: Fail to born 'com.hans.stock.ban.bean.Index5minKlineItem'
by args: [] because: No suitable Constructor or Factory Method!!
at org.nutz.lang.Mirror.born(Mirror.java:988)
at org.nutz.mapl.impl.convert.ObjConvertImpl.injectObj(ObjConvertImpl.java:190)
at org.nutz.mapl.impl.convert.ObjConvertImpl.inject(ObjConvertImpl.java:81)
at org.nutz.mapl.impl.convert.ObjConvertImpl.injectMap(ObjConvertImpl.java:137)
at org.nutz.mapl.impl.convert.ObjConvertImpl.inject(ObjConvertImpl.java:77)
at org.nutz.mapl.impl.convert.ObjConvertImpl.convert(ObjConvertImpl.java:65)
at org.nutz.mapl.Mapl.maplistToObj(Mapl.java:34)
at org.nutz.json.Json.parse(Json.java:79)
at org.nutz.json.Json.fromJson(Json.java:73)
at org.nutz.json.Json.fromJson(Json.java:95)
at org.nutz.lang.inject.InjectBySetter.inject(InjectBySetter.java:36)
at org.nutz.dao.impl.entity.field.AbstractEntityField.setValue(AbstractEntityField.java:53)
at org.nutz.dao.impl.entity.field.NutMappingField.injectValue(NutMappingField.java:87)
at org.nutz.dao.impl.entity.NutEntity.getObject(NutEntity.java:232)
at org.nutz.dao.impl.sql.pojo.PojoFetchEntityCallback.invoke(PojoFetchEntityCallback.java:21)
at org.nutz.dao.impl.jdbc.NutPojo.onAfter(NutPojo.java:109)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:277)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248)
at org.nutz.dao.impl.NutDao.fetch(NutDao.java:556)
at com.hans.stock.ban.StockManager2.updateIndex5minKline(StockManager2.java:784)
at com.hans.stock.ban.StockManager2.testFunc(StockManager2.java:1020)
at com.hans.stock.ban.StockManager2.main(StockManager2.java:1501)

5 回复

Index5minKlineItem缺无参数构造方法

我之前用的 json字段,对象是list xxx, 不需要写构造函数也是ok的,现在换成map而且我的构造函数无参、有参都有啊。

public Index5minKline(){
		
	}
	
	public Index5minKline(String zqdm, int date, Map<String, Index5minKlineItem> datas, boolean done) {
		this();
		this.zqdm = zqdm;
		this.date = date;
		this.datas = datas;
		this.done = done;
	}

求教详细说明

了解了,多谢

是Index5minKlineItem类, 看清楚类名

恩, 非常感谢

添加回复
请先登陆
回到顶部