Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.59 KB | None | 0 0
  1.  
  2. package com.oblivionsoftware.raid.entity;
  3.  
  4. /**
  5.  * Imports
  6.  */
  7. import java.io.Serializable;
  8. import java.util.Date;
  9. import javax.persistence.Column;
  10. import javax.persistence.Entity;
  11. import javax.persistence.GeneratedValue;
  12. import javax.persistence.GenerationType;
  13. import javax.persistence.Id;
  14. import javax.persistence.NamedQueries;
  15. import javax.persistence.NamedQuery;
  16. import javax.persistence.Table;
  17. import javax.persistence.Temporal;
  18. import javax.persistence.TemporalType;
  19. import javax.xml.bind.annotation.XmlRootElement;
  20.  
  21. /**
  22.  * User.
  23.  *
  24.  * @author Dustin Dobervich <ddobervich@gmail.com>
  25.  */
  26. @XmlRootElement(name="user")
  27. @Entity
  28. @Table(name="raid_users")
  29. @NamedQueries({
  30.     @NamedQuery(
  31.         name=User.FIND_BY_USERNAME,
  32.         query="SELECT u FROM User u WHERE u.username=:username"
  33.     ),
  34.     @NamedQuery(
  35.         name=User.FIND_BY_EMAIL,
  36.         query="SELECT u FROM User u WHERE u.email=:email"
  37.     )
  38. })
  39. public class User implements Serializable
  40. {    
  41.     private static final long serialVersionUID = 1L;
  42.     private static final String PREFIX = "User.";
  43.     public static final String FIND_BY_USERNAME = PREFIX + "findByUsername";
  44.     public static final String FIND_BY_EMAIL = PREFIX + "findByEmail";
  45.    
  46.     @Id
  47.     @GeneratedValue(strategy=GenerationType.SEQUENCE)
  48.     @Column(name="id", nullable=false)
  49.     private int id;
  50.    
  51.     @Column(name="username", unique=true, nullable=false)
  52.     private String username;
  53.    
  54.     @Column(name="email", unique=true, nullable=false)
  55.     private String email;
  56.    
  57.     @Column(name="password", nullable=false)
  58.     private String password;
  59.    
  60.     @Column(name="salt", nullable=false)
  61.     private String salt;
  62.    
  63.     @Temporal(TemporalType.TIMESTAMP)
  64.     @Column(name="last_login", nullable=false)
  65.     private Date lastLogin = new Date();
  66.    
  67.     @Temporal(TemporalType.TIMESTAMP)
  68.     @Column(name="created_at", nullable=false)
  69.     private Date createdAt = new Date();
  70.    
  71.     @Temporal(TemporalType.TIMESTAMP)
  72.     @Column(name="updated_at", nullable=false)
  73.     private Date updatedAt = new Date();
  74.    
  75.     /**
  76.      * Gets the id.
  77.      *
  78.      * @return The id
  79.      */
  80.     public int getId()
  81.     {
  82.         return this.id;
  83.     }
  84.    
  85.     /**
  86.      * Sets the id.
  87.      *
  88.      * @param id The id
  89.      */
  90.     public void setId(int id)
  91.     {
  92.         this.id = id;
  93.     }
  94.    
  95.     /**
  96.      * Gets the username.
  97.      *
  98.      * @return The username
  99.      */
  100.     public String getUsername()
  101.     {
  102.         return this.username;
  103.     }
  104.    
  105.     /**
  106.      * Sets the username.
  107.      *
  108.      * @param username The username
  109.      */
  110.     public void setUsername(String username)
  111.     {
  112.         this.username = username;
  113.     }
  114.    
  115.     /**
  116.      * Gets the email.
  117.      *
  118.      * @return The email
  119.      */
  120.     public String getEmail()
  121.     {
  122.         return this.email;
  123.     }
  124.    
  125.     /**
  126.      * Sets the email.
  127.      *
  128.      * @param email The email
  129.      */
  130.     public void setEmail(String email)
  131.     {
  132.         this.email = email;
  133.     }
  134.    
  135.     /**
  136.      * Gets the password.
  137.      *
  138.      * @return The password
  139.      */
  140.     public String getPassword()
  141.     {
  142.         return this.password;
  143.     }
  144.    
  145.     /**
  146.      * Sets the password.
  147.      *
  148.      * @param password The password
  149.      */
  150.     public void setPassword(String password)
  151.     {
  152.         this.password = password;
  153.     }
  154.    
  155.     /**
  156.      * Gets the salt.
  157.      *
  158.      * @return The salt
  159.      */
  160.     public String getSalt()
  161.     {
  162.         return this.salt;
  163.     }
  164.    
  165.     /**
  166.      * Sets the salt.
  167.      *
  168.      * @param salt The salt
  169.      */
  170.     public void setSalt(String salt)
  171.     {
  172.         this.salt = salt;
  173.     }
  174.    
  175.     /**
  176.      * Gets the last login date.
  177.      *
  178.      * @return The last login date
  179.      */
  180.     public Date getLastLogin()
  181.     {
  182.         return this.lastLogin;
  183.     }
  184.    
  185.     /**
  186.      * Sets the last login date.
  187.      *
  188.      * @param lastLogin The last login date
  189.      */
  190.     public void setLastLogin(Date lastLogin)
  191.     {
  192.         this.lastLogin = lastLogin;
  193.     }
  194.    
  195.     /**
  196.      * Gets the date created.
  197.      *
  198.      * @return The date created
  199.      */
  200.     public Date getCreatedAt()
  201.     {
  202.         return this.createdAt;
  203.     }
  204.    
  205.     /**
  206.      * Sets the date created.
  207.      *
  208.      * @param createdAt The date created
  209.      */
  210.     public void setCreatedAt(Date createdAt)
  211.     {
  212.         this.createdAt = createdAt;
  213.     }
  214.    
  215.     /**
  216.      * Gets the date updated.
  217.      *
  218.      * @return The date updated
  219.      */
  220.     public Date getUpdatedAt()
  221.     {
  222.         return this.updatedAt;
  223.     }
  224.    
  225.     /**
  226.      * Sets the date updated.
  227.      *
  228.      * @param createdAt The date updated
  229.      */
  230.     public void setUpdatedAt(Date updatedAt)
  231.     {
  232.         this.updatedAt = updatedAt;
  233.     }  
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement