问题描述
我想知道是否可以将@PrePersist
和@PreUpdate
与Ebean
和Play一起使用! 2.0.如果是这样,如何激活此功能.我已经看到一个月前有一个拉请求添加了此功能,但是我无法在Play 2.0上实现此功能.
I want to know if is it possible to use @PrePersist
and @PreUpdate
with Ebean
and Play! 2.0. If so how is this feature activated. I've seen that there was a pull request adding this feature a month ago, but I can't make this work on Play 2.0.
谢谢
推荐答案
如果您的目标只是设置createdAt或updatedAt字段,并且您正在使用EBean,请尝试@CreatedTimestamp
和@UpdatedTimestamp
.请参见此处.我更喜欢使用Biesior的方法,但是它在Cascades上似乎失败了-从未调用过这些方法.
If your goal is just setting createdAt or updatedAt fields, and you're using EBean, try @CreatedTimestamp
and @UpdatedTimestamp
. See here. I'd prefer to use Biesior's approach, but it seemed to fail on Cascades -- the methods were never called.
@Column(name="created_at")
@CreatedTimestamp
private Date createdAt;
@Column(name="updated_at")
@UpdatedTimestamp
private Date updatedAt;
这篇关于是否可以在eBean和Play中使用@PrePersist和@PreUpdate! 2.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!