Commit b2a982ed by jkj

comments

git-svn-id: https://dev.intra.insomnia.fi/svn/trunk@37 8cf89bec-f6a3-4178-919f-364fb3449fe5
1 parent 8470dd6d
...@@ -7,6 +7,7 @@ package fi.insomnia.bortal.model; ...@@ -7,6 +7,7 @@ package fi.insomnia.bortal.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import javax.persistence.Basic; import javax.persistence.Basic;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
...@@ -21,111 +22,112 @@ import javax.persistence.TemporalType; ...@@ -21,111 +22,112 @@ import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
/** /**
* * A vote for a compo entry
* @author jkj
*/ */
@Entity @Entity
@Table(name = "votes", uniqueConstraints = { @Table(name = "votes", uniqueConstraints = { @UniqueConstraint(columnNames = {
@UniqueConstraint(columnNames = {"entries_id", "users_id"})}) "entries_id", "users_id" }) })
@NamedQueries({ @NamedQueries( {
@NamedQuery(name = "Vote.findAll", query = "SELECT v FROM Vote v"), @NamedQuery(name = "Vote.findAll", query = "SELECT v FROM Vote v"),
@NamedQuery(name = "Vote.findByVotesId", query = "SELECT v FROM Vote v WHERE v.votesId = :votesId"), @NamedQuery(name = "Vote.findByVotesId", query = "SELECT v FROM Vote v WHERE v.votesId = :votesId"),
@NamedQuery(name = "Vote.findByScore", query = "SELECT v FROM Vote v WHERE v.score = :score"), @NamedQuery(name = "Vote.findByScore", query = "SELECT v FROM Vote v WHERE v.score = :score"),
@NamedQuery(name = "Vote.findByVoteTime", query = "SELECT v FROM Vote v WHERE v.voteTime = :voteTime")}) @NamedQuery(name = "Vote.findByVoteTime", query = "SELECT v FROM Vote v WHERE v.voteTime = :voteTime") })
public class Vote implements Serializable { public class Vote implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@Basic(optional = false) @Basic(optional = false)
@Column(name = "votes_id", nullable = false) @Column(name = "votes_id", nullable = false)
private Integer votesId; private Integer votesId;
@Column(name = "score") @Column(name = "score")
private Integer score; private Integer score;
@Basic(optional = false) @Basic(optional = false)
@Column(name = "vote_time", nullable = false) @Column(name = "vote_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date voteTime; private Date voteTime;
@JoinColumn(name = "entries_id", referencedColumnName = "entries_id", nullable = false) @JoinColumn(name = "entries_id", referencedColumnName = "entries_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private CompoEntry entriesId; private CompoEntry entriesId;
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false) @JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User usersId; private User usersId;
public Vote() { public Vote() {
} }
public Vote(Integer votesId) { public Vote(Integer votesId) {
this.votesId = votesId; this.votesId = votesId;
} }
public Vote(Integer votesId, Date voteTime) { public Vote(Integer votesId, Date voteTime) {
this.votesId = votesId; this.votesId = votesId;
this.voteTime = voteTime; this.voteTime = voteTime;
} }
public Integer getVotesId() { public Integer getVotesId() {
return votesId; return votesId;
} }
public void setVotesId(Integer votesId) { public void setVotesId(Integer votesId) {
this.votesId = votesId; this.votesId = votesId;
} }
public Integer getScore() { public Integer getScore() {
return score; return score;
} }
public void setScore(Integer score) { public void setScore(Integer score) {
this.score = score; this.score = score;
} }
public Date getVoteTime() { public Date getVoteTime() {
return voteTime; return voteTime;
} }
public void setVoteTime(Date voteTime) { public void setVoteTime(Date voteTime) {
this.voteTime = voteTime; this.voteTime = voteTime;
} }
public CompoEntry getEntriesId() { public CompoEntry getEntriesId() {
return entriesId; return entriesId;
} }
public void setEntriesId(CompoEntry entriesId) { public void setEntriesId(CompoEntry entriesId) {
this.entriesId = entriesId; this.entriesId = entriesId;
} }
public User getUsersId() { public User getUsersId() {
return usersId; return usersId;
} }
public void setUsersId(User usersId) { public void setUsersId(User usersId) {
this.usersId = usersId; this.usersId = usersId;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 0; int hash = 0;
hash += (votesId != null ? votesId.hashCode() : 0); hash += (votesId != null ? votesId.hashCode() : 0);
return hash; return hash;
} }
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set // TODO: Warning - this method won't work in the case the id fields are
if (!(object instanceof Vote)) { // not set
return false; if (!(object instanceof Vote)) {
} return false;
Vote other = (Vote) object; }
if ((this.votesId == null && other.votesId != null) || (this.votesId != null && !this.votesId.equals(other.votesId))) { Vote other = (Vote) object;
return false; if ((this.votesId == null && other.votesId != null)
} || (this.votesId != null && !this.votesId.equals(other.votesId))) {
return true; return false;
} }
return true;
@Override }
public String toString() {
return "fi.insomnia.bortal.model.Vote[votesId=" + votesId + "]"; @Override
} public String toString() {
return "fi.insomnia.bortal.model.Vote[votesId=" + votesId + "]";
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!