Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommenEntity命名 #3

Open
zlichao opened this issue Jun 21, 2017 · 1 comment
Open

CommenEntity命名 #3

zlichao opened this issue Jun 21, 2017 · 1 comment

Comments

@zlichao
Copy link

zlichao commented Jun 21, 2017

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

@zhengHongwei
Copy link
Owner

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格式显示

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants