我定义了一个bean:
package com.hans.stock.ban.bean;
import java.util.List;
import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.ColType;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.PK;
import org.nutz.dao.entity.annotation.Table;
@Table("t_test_obj")
@PK(value = { "zqdm"})
public class TestObj {
@Column
private String zqdm; //
@Column
private String zqmc; //
@Column
@ColDefine(type=ColType.MYSQL_JSON)
private List<String> reasons; //原因
public TestObj(){
}
public String getZqdm() {
return zqdm;
}
public void setZqdm(String zqdm) {
this.zqdm = zqdm;
}
public List<String> getReasons() {
return reasons;
}
public void setReasons(List<String> reasons) {
this.reasons = reasons;
}
public String getZqmc() {
return zqmc;
}
public void setZqmc(String zqmc) {
this.zqmc = zqmc;
}
}
然后采用Daos.createTablesInPackage(dao, "com.xxx.bean", false);这种方式自动建表
最后在方法中,插入到数据库(write方法),之后再查询出来(read方法),但是发现查询后的reasons 字段里面都是乱码
private void write(){
TestObj t = new TestObj();
t.setZqdm("002038");
t.setZqmc("双鹭药业");
List<String> reasons = new ArrayList<String>();
reasons.add("日跌幅偏离值达到7%的前五只证券");
reasons.add("日换手率达到20%的前五只证券");
t.setReasons(reasons);
dao.insert(t);
}
private void read(){
List<TestObj> list = dao.query(TestObj.class, Cnd.where("zqdm", "=", "002038"));
if(list!=null && list.size()>0){
TestObj t2 = list.get(0);
System.out.println(t2.getZqmc()); //这是对的,没有乱码
for(String r: t2.getReasons()){
System.out.println(r); //这是错的,乱了
}
}
我的数据库里面确实是正常的,中文都是正常,说明写入正常,这是bug吗?
用的nutz版本1.r.60