All pastes #576878 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-06-19 17:47 UTC
rendered paste body
package org.blog.domainmodel;import java.util.*;import javax.persistence.*;@Entity public class BlogEntry  implements java.io.Serializable{   public BlogEntry ()   { }  public BlogEntry (String _title, String _abstract, String _contents, Date _date, List<Tag> _tags, List<Reply> _replies, Enum_category _category, User _user)   {     this._title = _title;    this._abstract = _abstract;    this._contents = _contents;    this._date = _date;    this._tags = _tags;    this._replies = _replies;    this._category = _category;    this._user = _user;  }  private Long id;  @Id @GeneratedValue public Long getId()  {     return id;  }  public void setId(Long id)  {     this.id = id;  }  int versionNum;  @Version @Column(name = "OPTLOCK") protected int getVersionNum()  {     return versionNum;  }  protected void setVersionNum(int versionNum)  {     this.versionNum = versionNum;  }  private String _title;  @Basic public String getTitle()  {     return _title;  }  public void setTitle(String _title)  {     this._title = _title;  }  private String _abstract;  @Basic public String getAbstract()  {     return _abstract;  }  public void setAbstract(String _abstract)  {     this._abstract = _abstract;  }  private String _contents;  @Basic public String getContents()  {     return _contents;  }  public void setContents(String _contents)  {     this._contents = _contents;  }  private Date _date;  @Basic public Date getDate()  {     return _date;  }  public void setDate(Date _date)  {     this._date = _date;  }  private List<Tag> _tags;  @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) public List<Tag> getTags()  {     return _tags;  }  public void setTags(List<Tag> _tags)  {     this._tags = _tags;  }  public void addTags(Tag a_0)  {     if(this._tags == null)    {       this._tags = new ArrayList<Tag>();    }    this._tags.add(a_0);  }  public void removeTags(Tag a_0)  {     if(this._tags != null)    {       this._tags.remove(a_0);    }  }  private List<Reply> _replies;  @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) public List<Reply> getReplies()  {     return _replies;  }  public void setReplies(List<Reply> _replies)  {     this._replies = _replies;  }  public void addReplies(Reply b_0)  {     if(this._replies == null)    {       this._replies = new ArrayList<Reply>();    }    this._replies.add(b_0);  }  public void removeReplies(Reply b_0)  {     if(this._replies != null)    {       this._replies.remove(b_0);    }  }  public enum Enum_category   {     TECH("Technical"), NONTECH("Other")    ;    private String label;    Enum_category (String label)     {       this.label = label;    }    public String getLabel()    {       return label;    }    public String toString()    {       return label;    }    public Enum_category[] getValues()    {       return Enum_category.values();    }  }  private Enum_category _category;  @Basic @Enumerated(EnumType.ORDINAL) public Enum_category getCategory()  {     return _category;  }  public void setCategory(Enum_category _category)  {     this._category = _category;  }  private User _user;  @OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) public User getUser()  {     return _user;  }  public void setUser(User _user)  {     this._user = _user;  }  public @Override boolean equals(Object o)  {     if(o != null && o instanceof BlogEntry)    {       Long own_id = this.id;      Long other_id = ((BlogEntry)o).getId();      if(own_id != null && other_id != null)        return own_id.equals(other_id);      else        return this == o;    }    else      return false;  }  @Override public int hashCode()  {     return getId().intValue();  }  @Transient public String getToString()  {     return toString();  }  @Override public String toString()  {     StringBuilder name = new StringBuilder();    if(_title != null)    {       name.append(_title.toString());    }    return name.toString();  }}