2 * Copyright 2013 F.B.A. Scheper.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. *
16 package org.bitbucket.fbascheper.tutorial.envers;
18 import org.hibernate.envers.Audited;
19 import org.hibernate.envers.RevisionNumber;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import javax.persistence.SequenceGenerator;
27 import javax.persistence.Table;
28 import javax.persistence.Temporal;
29 import javax.persistence.TemporalType;
30 import javax.validation.constraints.NotNull;
31 import java.util.Date;
34 * A random event registered, based on the original hibernate tutorial by Steve Ebersole.
36 * @author Erik-Berndt Scheper
41 @Table(name = "TTL_EVENT")
47 @SequenceGenerator(name = "TTL_EVENT_SEQ", sequenceName = "TTL_EVENT_SEQ", allocationSize = 10)
48 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TTL_EVENT_SEQ")
53 @Column(name = "TITLE", length = 80, nullable = false)
57 @Column(name = "EVENT_DATE", nullable = false)
58 @Temporal(TemporalType.TIMESTAMP)
62 * Default constructor, mandated by JPA.
69 * Initializing constructor.
71 * @param title title of the event
72 * @param date date of the event
74 public Event(String title, Date date) {
79 // ********************** Getters and setters ********************** //
89 public Date getDate() {
93 public void setDate(Date date) {
97 public String getTitle() {
101 public void setTitle(String title) {
105 // ********************** Common Methods ********************** //
108 public boolean equals(Object o) {
109 if (this == o) return true;
110 if (o == null || getClass() != o.getClass()) return false;
112 Event event = (Event) o;
114 if (date != null ? !date.equals(event.date) : event.date != null) return false;
115 if (title != null ? !title.equals(event.title) : event.title != null) return false;
121 public int hashCode() {
122 int result = title != null ? title.hashCode() : 0;
123 result = 31 * result + (date != null ? date.hashCode() : 0);
128 public String toString() {
129 StringBuilder output = new StringBuilder();
131 output.append("Event {");
132 output.append(" id = \"").append(getId()).append("\", ");
133 output.append(" title = \"").append(title).append("\", ");
134 output.append(" date = \"").append(date).append("\"}");
136 return output.toString();