/*
* Copyright (c) JForum Team. All rights reserved.
*
* The software in this package is published under the terms of the LGPL
* license a copy of which has been included with this distribution in the
* license.txt file.
*
* The JForum Project
* http://www.jforum.net
*/
package net.jforum.entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.PrototypeScoped;
/**
* @author Rafael Steil
*/
@Entity
@Table(name = "jforum_topics_watch")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Component
@PrototypeScoped
public class TopicWatch implements Serializable {
@Id
@SequenceGenerator(name = "sequence", sequenceName = "jforum_topics_watch_seq")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "sequence")
@Column(name = "topics_watch_id")
private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "topic_id")
private Topic topic;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;
@Column(name = "is_read")
private boolean read;
/**
* @return the id
*/
public int getId() {
return this.id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the topicId
*/
public Topic getTopic() {
return this.topic;
}
/**
* @param topicId the topicId to set
*/
public void setTopic(Topic topic) {
this.topic = topic;
}
/**
* @return the userId
*/
public User getUser() {
return this.user;
}
/**
* @param userId the userId to set
*/
public void setUser(User user) {
this.user = user;
}
/**
* @return the read
*/
public boolean isRead() {
return this.read;
}
/**
* Mark this instance as read
*/
public void markAsRead() {
this.read = true;
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TopicWatch)) {
return false;
}
return ((TopicWatch)o).getId() == this.getId();
}
/**
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return this.getId();
}
}