Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.supinfo.supintweet.model;
- import java.io.Serializable;
- import java.util.List;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.JoinColumn;
- import javax.persistence.JoinTable;
- import javax.persistence.ManyToMany;
- import javax.persistence.NamedQueries;
- import javax.persistence.NamedQuery;
- /**
- *
- * @author smz
- */
- @NamedQueries(value={
- @NamedQuery(name="getAllAccount", query="SELECT p FROM Accounts p"),
- @NamedQuery(name="checkAccount", query="SELECT p FROM Accounts p where p.username=:username and p.password =:password")
- })
- @Entity
- public class Accounts implements Serializable {
- private static long serialVersionUID = 1L;
- /**
- * @return the serialVersionUID
- */
- public static long getSerialVersionUID() {
- return serialVersionUID;
- }
- /**
- * @param aSerialVersionUID the serialVersionUID to set
- */
- public static void setSerialVersionUID(long aSerialVersionUID) {
- serialVersionUID = aSerialVersionUID;
- }
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
- private String username;
- private String password;
- @ManyToMany
- @JoinTable(name="follows",
- joinColumns={@JoinColumn(name="following_id",referencedColumnName="id")},
- inverseJoinColumns={@JoinColumn(name="followers_id",referencedColumnName="id")})
- private List<Accounts> following;
- @ManyToMany(mappedBy="following")
- private List<Accounts> followers;
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- @Override
- public int hashCode() {
- int hash = 0;
- hash += (new Long(id)).hashCode() ;
- return hash;
- }
- @Override
- public boolean equals(Object object) {
- // TODO: Warning - this method won't work in the case the id fields are not set
- if (!(object instanceof Accounts)) {
- return false;
- }
- Accounts other = (Accounts) object;
- if (this.id == other.id ) {
- return false;
- }
- return true;
- }
- @Override
- public String toString() {
- return "com.supinfo.supintweet.model.Account[id=" + id + "]";
- }
- /**
- * @return the username
- */
- public String getUsername() {
- return username;
- }
- /**
- * @param username the username to set
- */
- public void setUsername(String username) {
- this.username = username;
- }
- /**
- * @return the password
- */
- public String getPassword() {
- return password;
- }
- /**
- * @param password the password to set
- */
- public void setPassword(String password) {
- this.password = password;
- }
- /**
- * @return the following
- */
- public List<Accounts> getFollowing() {
- return following;
- }
- /**
- * @param following the following to set
- */
- public void setFollowing(List<Accounts> following) {
- this.following = following;
- }
- /**
- * @return the followers
- */
- public List<Accounts> getFollowers() {
- return followers;
- }
- /**
- * @param followers the followers to set
- */
- public void setFollowers(List<Accounts> followers) {
- this.followers = followers;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement