Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 3.57 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 com.supinfo.supintweet.model;
  7.  
  8. import java.io.Serializable;
  9. import java.util.List;
  10. import javax.persistence.Entity;
  11. import javax.persistence.GeneratedValue;
  12. import javax.persistence.GenerationType;
  13. import javax.persistence.Id;
  14. import javax.persistence.JoinColumn;
  15. import javax.persistence.JoinTable;
  16. import javax.persistence.ManyToMany;
  17. import javax.persistence.NamedQueries;
  18. import javax.persistence.NamedQuery;
  19.  
  20. /**
  21.  *
  22.  * @author smz
  23.  */
  24.  
  25. @NamedQueries(value={
  26.     @NamedQuery(name="getAllAccount", query="SELECT p FROM Accounts p"),
  27.     @NamedQuery(name="checkAccount", query="SELECT p FROM Accounts p where p.username=:username and p.password =:password")
  28. })
  29. @Entity
  30. public class Accounts implements Serializable {
  31.     private static long serialVersionUID = 1L;
  32.  
  33.     /**
  34.      * @return the serialVersionUID
  35.      */
  36.     public static long getSerialVersionUID() {
  37.         return serialVersionUID;
  38.     }
  39.  
  40.     /**
  41.      * @param aSerialVersionUID the serialVersionUID to set
  42.      */
  43.     public static void setSerialVersionUID(long aSerialVersionUID) {
  44.         serialVersionUID = aSerialVersionUID;
  45.     }
  46.     @Id
  47.     @GeneratedValue(strategy = GenerationType.IDENTITY)
  48.     private Long id;
  49.     private String   username;
  50.     private String   password;
  51.  
  52.     @ManyToMany
  53.     @JoinTable(name="follows",
  54.     joinColumns={@JoinColumn(name="following_id",referencedColumnName="id")},
  55.     inverseJoinColumns={@JoinColumn(name="followers_id",referencedColumnName="id")})
  56.     private List<Accounts> following;
  57.     @ManyToMany(mappedBy="following")
  58.     private List<Accounts> followers;
  59.  
  60.  
  61.     public Long getId() {
  62.         return id;
  63.     }
  64.  
  65.     public void setId(Long id) {
  66.         this.id = id;
  67.     }
  68.  
  69.     @Override
  70.     public int hashCode() {
  71.         int hash = 0;
  72.         hash += (new Long(id)).hashCode() ;
  73.         return hash;
  74.     }
  75.  
  76.     @Override
  77.     public boolean equals(Object object) {
  78.         // TODO: Warning - this method won't work in the case the id fields are not set
  79.         if (!(object instanceof Accounts)) {
  80.             return false;
  81.         }
  82.         Accounts other = (Accounts) object;
  83.         if (this.id == other.id ) {
  84.             return false;
  85.         }
  86.         return true;
  87.     }
  88.  
  89.     @Override
  90.     public String toString() {
  91.         return "com.supinfo.supintweet.model.Account[id=" + id + "]";
  92.     }
  93.  
  94.     /**
  95.      * @return the username
  96.      */
  97.     public String getUsername() {
  98.         return username;
  99.     }
  100.  
  101.     /**
  102.      * @param username the username to set
  103.      */
  104.     public void setUsername(String username) {
  105.         this.username = username;
  106.     }
  107.  
  108.     /**
  109.      * @return the password
  110.      */
  111.     public String getPassword() {
  112.         return password;
  113.     }
  114.  
  115.     /**
  116.      * @param password the password to set
  117.      */
  118.     public void setPassword(String password) {
  119.         this.password = password;
  120.     }
  121.  
  122.     /**
  123.      * @return the following
  124.      */
  125.     public List<Accounts> getFollowing() {
  126.         return following;
  127.     }
  128.  
  129.     /**
  130.      * @param following the following to set
  131.      */
  132.     public void setFollowing(List<Accounts> following) {
  133.         this.following = following;
  134.     }
  135.  
  136.     /**
  137.      * @return the followers
  138.      */
  139.     public List<Accounts> getFollowers() {
  140.         return followers;
  141.     }
  142.  
  143.     /**
  144.      * @param followers the followers to set
  145.      */
  146.     public void setFollowers(List<Accounts> followers) {
  147.         this.followers = followers;
  148.     }
  149.  
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement