My gift to you.
package com.mycompany.data;
import java.util.Date;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
@Entity(name="Resource")
@Table(name="ag_resource")
public class Resource implements Serializable {
private Long id;
private String notes;
private byte[] byteArray;
private Date createdDate;
private String description;
private Date updatedDate;
private String name;
private String mimeType;
public Resource() {
setCreatedDate(new Date());
setUpdatedDate(new Date());
}
public void setId(final Long id) {
this.id = id;
}
@Id @GeneratedValue(strategy=GenerationType.AUTO)
public Long getId() {
return id;
}
public void setNotes(final String notes) {
this.notes = notes;
}
@Lob @Basic(fetch = FetchType.EAGER)
public String getNotes() {
return notes;
}
public void setByteArray(final byte[] byteArray) {
this.byteArray = byteArray;
}
@Lob @Basic(fetch = FetchType.EAGER)
public byte[] getByteArray() {
return byteArray;
}
public void setCreatedDate(final Date createdDate) {
this.createdDate = createdDate;
}
public Date getCreatedDate() {
return createdDate;
}
public void setDescription(final String description) {
this.description = description;
}
@Lob @Basic(fetch = FetchType.EAGER)
public String getDescription() {
return description;
}
public void setUpdatedDate(final Date updatedDate) {
this.updatedDate = updatedDate;
}
public Date getUpdatedDate() {
return updatedDate;
}
public void setName(final String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setMimeType(final String mimeType) {
this.mimeType = mimeType;
}
public String getMimeType() {
return mimeType;
}
public String toString() {
return new ToStringBuilder(this)
.append("name", getName())
.append("mimeType", getMimeType())
.append("notes", getNotes())
.append("createdDate", getCreatedDate())
.append("description", getDescription())
.append("updatedDate", getUpdatedDate())
.toString();
}
public boolean equals(Object object) {
if (!(object instanceof Resource)) return false;
Resource resource = (Resource) object;
return new EqualsBuilder()
.append(this.getName(), resource.getName())
.append(this.getMimeType(), resource.getMimeType())
.append(this.getNotes(), resource.getNotes())
.append(this.getCreatedDate(), resource.getCreatedDate())
.append(this.getDescription(), resource.getDescription())
.append(this.getUpdatedDate(), resource.getUpdatedDate())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getName())
.append(getMimeType())
.append(getNotes())
.append(getCreatedDate())
.append(getDescription())
.append(getUpdatedDate())
.toHashCode();
}
}