2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.rest.jpa;
24 import com.fasterxml.jackson.annotation.JsonBackReference;
26 import java.io.Serializable;
27 import java.util.Date;
29 import javax.persistence.Column;
30 import javax.persistence.Entity;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.Lob;
35 import javax.persistence.NamedQueries;
36 import javax.persistence.NamedQuery;
37 import javax.persistence.PrePersist;
38 import javax.persistence.PreUpdate;
39 import javax.persistence.Table;
40 import javax.persistence.Temporal;
41 import javax.persistence.TemporalType;
42 import javax.persistence.Version;
45 import lombok.NoArgsConstructor;
49 * The Entity class to persist a policy object Action Body
53 @Table(name = "ActionBodyEntity")
56 @NamedQuery(name = " ActionBodyEntity.findAll", query = "SELECT e FROM ActionBodyEntity e "),
57 @NamedQuery(name = "ActionBodyEntity.deleteAll", query = "DELETE FROM ActionBodyEntity WHERE 1=1")
65 public class ActionBodyEntity implements Serializable {
66 private static final long serialVersionUID = 1L;
69 @GeneratedValue(strategy = GenerationType.AUTO)
70 @Column(name = "actionBodyId")
72 private long actionBodyId;
74 @Column(name = "actionBodyName", nullable = false, length = 255)
75 private String actionBodyName = "";
78 @Column(name = "version")
82 @Column(name = "actionBody", nullable = false, columnDefinition = "TEXT")
83 private String actionBody = "NoBody";
85 @Column(name = "created_by", nullable = false, length = 255)
86 private String createdBy = "guest";
88 @Temporal(TemporalType.TIMESTAMP)
89 @Column(name = "created_date", updatable = false)
90 private Date createdDate;
92 @Column(name = "modified_by", nullable = false, length = 255)
93 private String modifiedBy = "guest";
95 @Temporal(TemporalType.TIMESTAMP)
96 @Column(name = "modified_date", nullable = false)
97 private Date modifiedDate;
99 @Column(name = "deleted", nullable = false)
100 private boolean deleted = false;
103 * Called before an instance is persisted.
106 public void prePersist() {
107 Date date = new Date();
108 this.createdDate = date;
109 this.modifiedDate = date;
113 * Called before an instance is updated.
116 public void preUpdate() {
117 this.modifiedDate = new Date();