Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.67 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package model;
  7.  
  8. import java.io.Serializable;
  9. import java.util.List;
  10. import javax.persistence.Basic;
  11. import javax.persistence.Column;
  12. import javax.persistence.Entity;
  13. import javax.persistence.Id;
  14. import javax.persistence.NamedQueries;
  15. import javax.persistence.NamedQuery;
  16. import javax.persistence.OneToMany;
  17. import javax.persistence.Table;
  18.  
  19. /**
  20.  *
  21.  * @author Oz
  22.  */
  23. @Entity
  24. @Table(name = "users")
  25. @NamedQueries({
  26.     @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
  27.     @NamedQuery(name = "Users.findByUsername", query = "SELECT u FROM Users u WHERE u.username = :username"),
  28.     @NamedQuery(name = "Users.findByPassword", query = "SELECT u FROM Users u WHERE u.password = :password")})
  29. public class Users implements Serializable {
  30.     private static final long serialVersionUID = 1L;
  31.     @Id
  32.     @Basic(optional = false)
  33.     @Column(name = "username")
  34.     private String username;
  35.     @Basic(optional = false)
  36.     @Column(name = "password")
  37.     private String password;
  38.     @OneToMany(mappedBy = "users")
  39.     private List<Guestbook> guestbookList;
  40.  
  41.     public Users() {
  42.     }
  43.  
  44.     public Users(String username) {
  45.         this.username = username;
  46.     }
  47.  
  48.     public Users(String username, String password) {
  49.         this.username = username;
  50.         this.password = password;
  51.     }
  52.  
  53.     public String getUsername() {
  54.         return username;
  55.     }
  56.  
  57.     public void setUsername(String username) {
  58.         this.username = username;
  59.     }
  60.  
  61.     public String getPassword() {
  62.         return password;
  63.     }
  64.  
  65.     public void setPassword(String password) {
  66.         this.password = password;
  67.     }
  68.  
  69.     public List<Guestbook> getGuestbookList() {
  70.         return guestbookList;
  71.     }
  72.  
  73.     public void setGuestbookList(List<Guestbook> guestbookList) {
  74.         this.guestbookList = guestbookList;
  75.     }
  76.  
  77.     @Override
  78.     public int hashCode() {
  79.         int hash = 0;
  80.         hash += (username != null ? username.hashCode() : 0);
  81.         return hash;
  82.     }
  83.  
  84.     @Override
  85.     public boolean equals(Object object) {
  86.         // TODO: Warning - this method won't work in the case the id fields are not set
  87.         if (!(object instanceof Users)) {
  88.             return false;
  89.         }
  90.         Users other = (Users) object;
  91.         if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
  92.             return false;
  93.         }
  94.         return true;
  95.     }
  96.  
  97.     @Override
  98.     public String toString() {
  99.         return "model.Users[username=" + username + "]";
  100.     }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement