java 反射 fields数量变多

1.这是反射过程

   @Override
    protected String createTable(String tableName,Class bean) {


        Field[]  fields= bean.getDeclaredFields();
        StringBuilder stringBuilder =new StringBuilder();
        stringBuilder.append("create table if not exists "+tableName+" ( ");
        for (int i = 0; i <fields.length ; i++) {
            TLog.error(fields[i].getName());
            if (i==fields.length-1){
                stringBuilder.append(" "+fields[i].getName()+" varchar(40)");
            }else {
                stringBuilder.append(" "+fields[i].getName()+" varchar(40),");

            }
        }

        stringBuilder.append(" );");
        return stringBuilder.toString();
    }

2.这是反射的bean对象

public class City {

    public City(String id, String name, String cityCode) {
        this.id = id;
        this.name = name;
        this.cityCode = cityCode;
    }


    public String id;

    public String name;

    public String cityCode;



}

3.这是log日志

01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: cityCode
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: id
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: name
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: $change
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: serialVersionUID
慕哥9229398
浏览 431回答 3
3回答

萧十郎

你确定你的pojo没有被序列化?

holdtom

$change什么鬼不太懂,serialVersionUID实现序列化接口就会有,一般Bean都会实现这个接口,可以对字段统一做个过滤
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java