Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. package domain;
  2.  
  3. import javax.persistence.*;
  4.  
  5. /**
  6. * Account entity containing login credentials
  7. *
  8. * An account entity always belongs to a single owner entity
  9. * @see Owner
  10. */
  11. @Entity
  12. @Table(name = "ACCOUNT")
  13. @NamedQueries({
  14. @NamedQuery(
  15. name = "Account.auth",
  16. query = "SELECT u FROM Account u WHERE u.username = :username AND u.password = :password"
  17. )
  18. })
  19. public class Account {
  20. @Id
  21. @GeneratedValue(strategy = GenerationType.IDENTITY)
  22. @Column(name = "ID")
  23. private Long id;
  24. @Column(unique = true, name = "USERNAME")
  25. private String username;
  26. @Column(name = "PASSWORD")
  27. private String password;
  28. @OneToOne(cascade = CascadeType.PERSIST)
  29. @JoinColumn(name = "OWNER_ID")
  30. private Owner details;
  31.  
  32. public Account() {
  33.  
  34. }
  35.  
  36. public Account(String username, String password) {
  37. this.username = username;
  38. this.password = password;
  39. }
  40.  
  41. public Account(Long id, String username, String password) {
  42. this.id = id;
  43. this.username = username;
  44. this.password = password;
  45. }
  46.  
  47. public Account(String username, String password, Owner details) {
  48. this.username = username;
  49. this.password = password;
  50. this.details = details;
  51. }
  52.  
  53. public Long getId() {
  54. return id;
  55. }
  56.  
  57. public void setId(Long id) {
  58. this.id = id;
  59. }
  60.  
  61. public String getUsername() {
  62. return username;
  63. }
  64.  
  65. public void setUsername(String username) {
  66. this.username = username;
  67. }
  68.  
  69. public String getPassword() {
  70. return password;
  71. }
  72.  
  73. public void setPassword(String password) {
  74. this.password = password;
  75. }
  76.  
  77. public Owner getDetails() {
  78. return details;
  79. }
  80.  
  81. public void setDetails(Owner details) {
  82. this.details = details;
  83. }
  84.  
  85. @Override
  86. public String toString() {
  87. return "id: " + id
  88. + " username: " + username
  89. + " password: " + password;
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement