Java tutorial
/* * Copyright (C) 2016 Dominik Schadow, dominikschadow@gmail.com * * This file is part of the Application Intrusion Detection project. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.dominikschadow.duke.encounters.domain; import org.apache.commons.lang3.builder.ToStringBuilder; import org.springframework.format.annotation.DateTimeFormat; import javax.persistence.*; import java.util.Date; /** * Represents a single confirmation of a single encounter. * * @author Dominik Schadow */ @Entity @Table(name = "confirmations") public class Confirmation { @Id @GeneratedValue private long id; @ManyToOne @JoinColumn(name = "user_id", nullable = false) private DukeEncountersUser user; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "encounter_id", nullable = false) private Encounter encounter; @DateTimeFormat(pattern = "MM/dd/yyyy") private Date date; public long getId() { return id; } public void setId(long id) { this.id = id; } public DukeEncountersUser getUser() { return user; } public void setUser(DukeEncountersUser user) { this.user = user; } public Encounter getEncounter() { return encounter; } public void setEncounter(Encounter encounter) { this.encounter = encounter; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } @Override public String toString() { return new ToStringBuilder(this).append("id", getId()).append("user", getUser()) .append("encounter", getEncounter()).append("date", getDate()).toString(); } }