springmvc icon indicating copy to clipboard operation
springmvc copied to clipboard

CommenEntity命名

Open zlichao opened this issue 7 years ago • 1 comments

应该是CommonEntity吧。 继承自这个类的实体,里面就可以隐藏create_date这种时间戳记录字段,想法很好,是可以实现吗?学习了。接下来在项目中试试。 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00") 这个注解,可以解决实体按照JSON格式传递的问题吗?

zlichao avatar Jun 21 '17 08:06 zlichao

CommonEntity是所有实体的父类,此父类有个监听类EntityListener,这样凡是继承了CommonEntity类的子类在持久化时会自动执行EntityListener中的prePersist方法 public void prePersist(CommenEntity ce){ ce.setCreateDate(new Date()); ce.setLastUpdateDate(new Date()); } 在修改时会自动执行preUpdate方法 public void preUpdate(CommenEntity ce){ ce.setLastUpdateDate(new Date()); } 可以减少一部分公共代码的开发。 关于@jsonformat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")目的时在在页面展示时日期以yyyy-MM-dd HH:mm:ss格式显示

zhengHongwei avatar Jul 25 '17 01:07 zhengHongwei