是否可以在 Hibernate 中重用定义的列?
我有大约 20 个表,每个表都需要至少修改和创建以及所有这些列都相同的其他一些字段。
我试过这样做:
public class ModifiedCreated {
@Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(style = "M-")
private Date created;
@Version
@Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(style = "M-")
private Date modified;
public ModifiedCreated() {
created = new Date();
modified = new Date();
}
@PrePersist
protected void onPersist() {
if (created == null) {
created = new Date();
}
if (modified == null) {
modified = new Date();
}
}
@PreUpdate
protected void onUpdate() {
modified = new Date();
}
public Date getModified() {
return modified;
}
public Date getCreated() {
return created;
}
}
和 Route.java
@RooJavaBean
@RooToString
@RooEntity
public class Route extends ModifiedCreated {
private String name;
@ManyToMany(cascade = CascadeType.ALL)
private Set<Note> notes = new HashSet<Note>();
}
是否可以在 Hibernate 中重用列?