/* * Copyright (c) 2015 NIBIO <http://www.nibio.no/>. * * This file is part of VIPSLogic. * VIPSLogic is free software: you can redistribute it and/or modify * it under the terms of the NIBIO Open Source License as published by * NIBIO, either version 1 of the License, or (at your option) any * later version. * * VIPSLogic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * NIBIO Open Source License for more details. * * You should have received a copy of the NIBIO Open Source License * along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. * */ package no.nibio.vips.logic.entity; import java.io.Serializable; import java.util.UUID; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Embeddable; import javax.validation.constraints.NotNull; /** * @copyright 2015 <a href="http://www.nibio.no/">NIBIO</a> * @author Tor-Einar Skog <tor-einar.skog@nibio.no> */ @Embeddable public class UserUuidPK implements Serializable { @Basic(optional = false) @NotNull @Column(name = "user_uuid") @org.hibernate.annotations.Type(type="pg-uuid") // Ugly implementation specific hack private UUID userUuid; @Basic(optional = false) @NotNull @Column(name = "user_id") private int userId; public UserUuidPK() { } public UserUuidPK(UUID userUuid, int userId) { this.userUuid = userUuid; this.userId = userId; } public UUID getUserUuid() { return userUuid; } public void setUserUuid(UUID userUuid) { this.userUuid = userUuid; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } @Override public int hashCode() { int hash = 0; hash += (userUuid != null ? userUuid.hashCode() : 0); hash += (int) userId; return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof UserUuidPK)) { return false; } UserUuidPK other = (UserUuidPK) object; if ((this.userUuid == null && other.userUuid != null) || (this.userUuid != null && !this.userUuid.equals(other.userUuid))) { return false; } if (this.userId != other.userId) { return false; } return true; } @Override public String toString() { return "no.nibio.vips.logic.entity.UserUuidPK[ userUuid=" + userUuid + ", userId=" + userId + " ]"; } }