View Javadoc
1   package com.entity;
2   
3   /*
4    * #%L
5    * Gateway
6    * %%
7    * Copyright (C) 2015 Powered by Sergey
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  
24  import org.springframework.data.annotation.CreatedBy;
25  import org.springframework.data.annotation.CreatedDate;
26  import org.springframework.data.annotation.LastModifiedBy;
27  import org.springframework.data.annotation.LastModifiedDate;
28  import org.springframework.data.jpa.domain.support.AuditingEntityListener;
29  
30  import javax.persistence.*;
31  import java.util.Date;
32  
33  /**
34   * Created by aautushk on 9/12/2015.
35   */
36  @EntityListeners(AuditingEntityListener.class)
37  @MappedSuperclass
38  public abstract class BaseEntity {
39      @Column(name = "created_by_user", nullable = false)
40      @CreatedBy
41      private String createdByUser;
42  
43      @Column(name = "created_at", nullable = false)
44      @CreatedDate
45      @Temporal(TemporalType.TIMESTAMP)
46      private Date createdAt;
47  
48      @Column(name = "modified_by_user", nullable = false)
49      @LastModifiedBy
50      private String modifiedByUser;
51  
52      @Column(name = "modified_at", nullable = false)
53      @LastModifiedDate
54      @Temporal(TemporalType.TIMESTAMP)
55      private Date modifiedAt;
56  
57      @Column(name = "version", nullable = false)
58      @Version
59      private Long version;
60  
61      public String getCreatedByUser() {
62          return createdByUser;
63      }
64  
65      public void setCreatedByUser(String createdByUser) {
66          this.createdByUser = createdByUser;
67      }
68  
69      public Date getCreatedAt() {
70          return createdAt;
71      }
72  
73      public void setCreatedAt(Date createdAt) {
74          this.createdAt = createdAt;
75      }
76  
77      public String getModifiedByUser() {
78          return modifiedByUser;
79      }
80  
81      public void setModifiedByUser(String modifiedByUser) {
82          this.modifiedByUser = modifiedByUser;
83      }
84  
85      public Date getModifiedAt() {
86          return modifiedAt;
87      }
88  
89      public void setModifiedAt(Date modifiedAt) {
90          this.modifiedAt = modifiedAt;
91      }
92  }