1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.core.entity;
17
18 import java.util.Date;
19
20 import javax.persistence.Embedded;
21 import javax.persistence.MappedSuperclass;
22
23 import org.kuali.student.common.util.security.SecurityUtils;
24
25 @MappedSuperclass
26 public abstract class MetaEntity extends BaseEntity{
27
28 @Embedded
29 private Meta meta;
30
31 @Override
32 protected void onPrePersist(){
33 super.onPrePersist();
34 if(meta==null){
35 meta = new Meta();
36 }
37 meta.setCreateTime(new Date());
38 meta.setUpdateTime(new Date());
39
40 String user = SecurityUtils.getCurrentUserId();
41 meta.setCreateId(user);
42 meta.setUpdateId(user);
43
44 }
45
46 @Override
47 protected void onPreUpdate(){
48 super.onPreUpdate();
49
50 if(meta==null){
51 meta = new Meta();
52 meta.setCreateTime(new Date());
53 }
54
55 meta.setUpdateTime(new Date());
56
57 String user = SecurityUtils.getCurrentUserId();
58 meta.setUpdateId(user);
59 }
60
61 public Meta getMeta() {
62 return meta;
63 }
64
65 public void setMeta(Meta meta) {
66 this.meta = meta;
67 }
68 }