2 * Copyright (C) 2016 - 2022 Free Software Foundation
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jjobs.model.user.skills;
19 import org.mxchange.jjobs.model.skill.JobSkill;
20 import org.mxchange.jjobs.model.skill.Skillable;
21 import java.util.Date;
22 import java.util.Objects;
23 import javax.persistence.Basic;
24 import javax.persistence.CascadeType;
25 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.GeneratedValue;
28 import javax.persistence.GenerationType;
29 import javax.persistence.Id;
30 import javax.persistence.JoinColumn;
31 import javax.persistence.OneToOne;
32 import javax.persistence.Table;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35 import org.mxchange.jusercore.model.user.LoginUser;
36 import org.mxchange.jusercore.model.user.User;
39 * A POJO entity for user skills
41 * @author Roland Häder<roland@mxchange.org>
43 @Entity (name = "user_skills")
47 @SuppressWarnings ("PersistenceUnitPresent")
48 public class UserSkill implements SkillableUser {
53 private static final long serialVersionUID = 12_837_674_186_902L;
56 * Link to skills entity
58 @JoinColumn (name = "user_skill_id", referencedColumnName = "skill_id", nullable = false, updatable = false)
59 @OneToOne (cascade = CascadeType.REFRESH, optional = false, targetEntity = JobSkill.class)
60 private Skillable jobSkill;
65 @JoinColumn (name = "user_skill_user_id", referencedColumnName = "user_id", nullable = false, updatable = false)
66 @OneToOne (cascade = CascadeType.REFRESH, optional = false, targetEntity = LoginUser.class)
67 private User skillUser;
70 * When this entry has been created
72 @Basic (optional = false)
73 @Column (name = "user_skill_created", nullable = false, updatable = false)
74 @Temporal (TemporalType.TIMESTAMP)
75 private Date userSkillCreated;
78 * Id number (primary key)
81 @GeneratedValue (strategy = GenerationType.IDENTITY)
82 @Column (name = "user_skill_entry_id", nullable = false, updatable = false)
83 private Long userSkillId;
86 * When this entry has been updated
88 @Column (name = "user_skill_updated", insertable = false)
89 @Temporal (TemporalType.TIMESTAMP)
90 private Date userSkillUpdated;
93 * Default constructor, required for the EJB
100 * Constructor with all required entity properties
102 * @param jobSkill An instance of a Skillable class
103 * @param skillUser An instance of a User class
105 public UserSkill (final Skillable jobSkill, final User skillUser) {
106 // Invoke default constructor
109 // Validate parameter
110 if (null == jobSkill) {
112 throw new NullPointerException("jobSkill is null"); //NOI18N
113 } else if (null == skillUser) {
115 throw new NullPointerException("skillUser is null"); //NOI18N
119 this.jobSkill = jobSkill;
120 this.skillUser = skillUser;
124 public boolean equals (final Object object) {
125 if (this == object) {
127 } else if (object == null) {
129 } else if (getClass() != object.getClass()) {
133 final SkillableUser skillableUser = (SkillableUser) object;
135 if (!Objects.equals(this.getJobSkill(), skillableUser.getJobSkill())) {
137 } else if (!Objects.equals(this.getSkillUser(), skillableUser.getSkillUser())) {
139 } else if (!Objects.equals(this.getUserSkillId(), skillableUser.getUserSkillId())) {
147 public int hashCode () {
150 hash = 17 * hash + Objects.hashCode(this.getJobSkill());
151 hash = 17 * hash + Objects.hashCode(this.getSkillUser());
152 hash = 17 * hash + Objects.hashCode(this.getUserSkillId());
158 public Skillable getJobSkill () {
159 return this.jobSkill;
163 public void setJobSkill (final Skillable jobSkill) {
164 this.jobSkill = jobSkill;
168 public User getSkillUser () {
169 return this.skillUser;
173 public void setSkillUser (final User skillUser) {
174 this.skillUser = skillUser;
178 @SuppressWarnings ("ReturnOfDateField")
179 public Date getUserSkillCreated () {
180 return this.userSkillCreated;
184 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
185 public void setUserSkillCreated (final Date userSkillCreated) {
186 this.userSkillCreated = userSkillCreated;
190 public Long getUserSkillId () {
191 return this.userSkillId;
195 public void setUserSkillId (final Long userSkillId) {
196 this.userSkillId = userSkillId;
200 @SuppressWarnings ("ReturnOfDateField")
201 public Date getUserSkillUpdated () {
202 return this.userSkillUpdated;
206 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
207 public void setUserSkillUpdated (final Date userSkillUpdated) {
208 this.userSkillUpdated = userSkillUpdated;