gson 显示 mysql数据_求救。。查数据库的值显示为NULL,但是转JSON的时候显示出来了值...

public String findCommentByNewsId(String id) {

Integer i = Integer.parseInt(id);

System.out.println("service = " + new CommentDao().findCommentByNewsId(i).toString());

System.out.println("serviceGson = " + new Gson().toJson(new CommentDao().findCommentByNewsId(i)));

return new Gson().toJson(new CommentDao().findCommentByNewsId(i));

}public List findCommentByNewsId(int id){

System.out.println("dao = " + Comment.dao.find("select * from comment_info where comment_belone = ?",id).toString());

return Comment.dao.find("select * from comment_info where comment_belone = " + id);

}dao = [Comment{comment_id=null, comment_author=null, comment_class=null, comment_content='null', comment_likeNum=null, comment_time=null, comment_belone=null}, Comment{comment_id=null, comment_author=null, comment_class=null, comment_content='null', comment_likeNum=null, comment_time=null, comment_belone=null}]

service = [Comment{comment_id=null, comment_author=null, comment_class=null, comment_content='null', comment_likeNum=null, comment_time=null, comment_belone=null}, Comment{comment_id=null, comment_author=null, comment_class=null, comment_content='null', comment_likeNum=null, comment_time=null, comment_belone=null}]

serviceGson = [{"attrs":{"comment_likenum":12,"comment_time":"十一月 27, 2019","comment_belone":1,"comment_author":1,"comment_class":3,"commentId":1,"comment_content":"涌起的情绪一言两语说不清楚,惊喜中带着不置信,随之而来的感动。"}},{"attrs":{"comment_likenum":23,"comment_time":"十一月 28, 2019","comment_belone":1,"comment_author":1,"comment_class":3,"commentId":2,"comment_content":"涌起的情绪一言两语说不清楚,惊喜中带着不置信,随之而来的感动。"}}]

转JSON的时候他居然能在控制台输出出来数据,但是两个调用toString方法打印出来的却是nullpublic class Comment extends Model{

private Integer commentId;

private Integer comment_author;

private Integer comment_class;

private String comment_content;

private Integer comment_likeNum;

private Date comment_time;

private Integer comment_belone;

public static final Comment dao = new Comment().dao();

public Comment(){}

public Integer getCommentId() {

return commentId;

}

public void setCommentId(Integer comment_id) {

this.commentId = comment_id;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值