package com.insoul.copartner.domain; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; @Entity @Table(name = "message", catalog = "copartner") @NamedQueries({ @NamedQuery(name = "Message.getMessageCountByAccountAndChannel", query = "SELECT COUNT(*) FROM Message m WHERE m.account = :account AND m.channelId = :channelId AND m.created >= :startDateTime AND m.created <= :endDateTime") }) public class Message extends BaseEntity { private static final long serialVersionUID = 3183648919517830035L; @Column(name = "message_type_id", nullable = false) private Integer messageTypeId; @Column(name = "channel_id", nullable = false) private Integer channelId; @Column(name = "user_id") private Long userId; @Column(name = "account", nullable = false) private String account; @Column(name = "subject", nullable = false) private String subject; @Column(name = "content", nullable = false) private String content; @Column(name = "`status`", nullable = false) private String status = "processing"; public Integer getMessageTypeId() { return messageTypeId; } public void setMessageTypeId(Integer messageTypeId) { this.messageTypeId = messageTypeId; } public Integer getChannelId() { return channelId; } public void setChannelId(Integer channelId) { this.channelId = channelId; } public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public String getAccount() { return account; } public void setAccount(String account) { this.account = account; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((account == null) ? 0 : account.hashCode()); result = prime * result + ((channelId == null) ? 0 : channelId.hashCode()); result = prime * result + ((content == null) ? 0 : content.hashCode()); result = prime * result + ((messageTypeId == null) ? 0 : messageTypeId.hashCode()); result = prime * result + ((status == null) ? 0 : status.hashCode()); result = prime * result + ((subject == null) ? 0 : subject.hashCode()); result = prime * result + ((userId == null) ? 0 : userId.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; Message other = (Message) obj; if (account == null) { if (other.account != null) return false; } else if (!account.equals(other.account)) return false; if (channelId == null) { if (other.channelId != null) return false; } else if (!channelId.equals(other.channelId)) return false; if (content == null) { if (other.content != null) return false; } else if (!content.equals(other.content)) return false; if (messageTypeId == null) { if (other.messageTypeId != null) return false; } else if (!messageTypeId.equals(other.messageTypeId)) return false; if (status == null) { if (other.status != null) return false; } else if (!status.equals(other.status)) return false; if (subject == null) { if (other.subject != null) return false; } else if (!subject.equals(other.subject)) return false; if (userId == null) { if (other.userId != null) return false; } else if (!userId.equals(other.userId)) return false; return true; } }