/samples/bookmark-em/src/main/java/com/sun/jersey/samples/bookmark_em/entities/UserEntity.java

https://github.com/akollegger/akka-jersey-samples · Java · 225 lines · 90 code · 25 blank · 110 comment · 7 complexity · c2750131e77a66b77d60500b3009050c MD5 · raw file

  1. /*
  2. *
  3. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  4. *
  5. * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
  6. *
  7. * The contents of this file are subject to the terms of either the GNU
  8. * General Public License Version 2 only ("GPL") or the Common Development
  9. * and Distribution License("CDDL") (collectively, the "License"). You
  10. * may not use this file except in compliance with the License. You can obtain
  11. * a copy of the License at https://jersey.dev.java.net/CDDL+GPL.html
  12. * or jersey/legal/LICENSE.txt. See the License for the specific
  13. * language governing permissions and limitations under the License.
  14. *
  15. * When distributing the software, include this License Header Notice in each
  16. * file and include the License file at jersey/legal/LICENSE.txt.
  17. * Sun designates this particular file as subject to the "Classpath" exception
  18. * as provided by Sun in the GPL Version 2 section of the License file that
  19. * accompanied this code. If applicable, add the following below the License
  20. * Header, with the fields enclosed by brackets [] replaced by your own
  21. * identifying information: "Portions Copyrighted [year]
  22. * [name of copyright owner]"
  23. *
  24. * Contributor(s):
  25. *
  26. * If you wish your version of this file to be governed by only the CDDL or
  27. * only the GPL Version 2, indicate your decision by adding "[Contributor]
  28. * elects to include this software in this distribution under the [CDDL or GPL
  29. * Version 2] license." If you don't indicate a single choice of license, a
  30. * recipient has the option to distribute your version of this file under
  31. * either the CDDL, the GPL Version 2 or to extend the choice of license to
  32. * its licensees as provided above. However, if you add GPL Version 2 code
  33. * and therefore, elected the GPL Version 2 license, then the option applies
  34. * only if the new code is made subject to such option by the copyright
  35. * holder.
  36. */
  37. package com.sun.jersey.samples.bookmark_em.entities;
  38. import java.io.Serializable;
  39. import java.util.Collection;
  40. import javax.persistence.CascadeType;
  41. import javax.persistence.Column;
  42. import javax.persistence.Entity;
  43. import javax.persistence.Id;
  44. import javax.persistence.NamedQueries;
  45. import javax.persistence.NamedQuery;
  46. import javax.persistence.OneToMany;
  47. import javax.persistence.Table;
  48. /**
  49. * Entity class UserEntity
  50. *
  51. * @author japod
  52. */
  53. @Entity
  54. @Table(name = "USERS")
  55. @NamedQueries( {
  56. @NamedQuery(name = "UserEntity.findByUserid", query = "SELECT u FROM UserEntity u WHERE u.userid = :userid"),
  57. @NamedQuery(name = "UserEntity.findByPassword", query = "SELECT u FROM UserEntity u WHERE u.password = :password"),
  58. @NamedQuery(name = "UserEntity.findByUsername", query = "SELECT u FROM UserEntity u WHERE u.username = :username"),
  59. @NamedQuery(name = "UserEntity.findByEmail", query = "SELECT u FROM UserEntity u WHERE u.email = :email")
  60. })
  61. public class UserEntity implements Serializable {
  62. @Id
  63. @Column(name = "USERID", nullable = false)
  64. private String userid;
  65. @Column(name = "PASSWORD", nullable = false)
  66. private String password;
  67. @Column(name = "USERNAME")
  68. private String username;
  69. @Column(name = "EMAIL")
  70. private String email;
  71. @OneToMany(cascade = CascadeType.ALL, mappedBy = "userEntity")
  72. private Collection<BookmarkEntity> bookmarkEntityCollection;
  73. /** Creates a new instance of UserEntity */
  74. public UserEntity() {
  75. }
  76. /**
  77. * Creates a new instance of UserEntity with the specified values.
  78. * @param userid the userid of the UserEntity
  79. */
  80. public UserEntity(String userid) {
  81. this.userid = userid;
  82. }
  83. /**
  84. * Creates a new instance of UserEntity with the specified values.
  85. * @param userid the userid of the UserEntity
  86. * @param password the password of the UserEntity
  87. */
  88. public UserEntity(String userid, String password) {
  89. this.userid = userid;
  90. this.password = password;
  91. }
  92. /**
  93. * Gets the userid of this UserEntity.
  94. * @return the userid
  95. */
  96. public String getUserid() {
  97. return this.userid;
  98. }
  99. /**
  100. * Sets the userid of this UserEntity to the specified value.
  101. * @param userid the new userid
  102. */
  103. public void setUserid(String userid) {
  104. this.userid = userid;
  105. }
  106. /**
  107. * Gets the password of this UserEntity.
  108. * @return the password
  109. */
  110. public String getPassword() {
  111. return this.password;
  112. }
  113. /**
  114. * Sets the password of this UserEntity to the specified value.
  115. * @param password the new password
  116. */
  117. public void setPassword(String password) {
  118. this.password = password;
  119. }
  120. /**
  121. * Gets the username of this UserEntity.
  122. * @return the username
  123. */
  124. public String getUsername() {
  125. return this.username;
  126. }
  127. /**
  128. * Sets the username of this UserEntity to the specified value.
  129. * @param username the new username
  130. */
  131. public void setUsername(String username) {
  132. this.username = username;
  133. }
  134. /**
  135. * Gets the email of this UserEntity.
  136. * @return the email
  137. */
  138. public String getEmail() {
  139. return this.email;
  140. }
  141. /**
  142. * Sets the email of this UserEntity to the specified value.
  143. * @param email the new email
  144. */
  145. public void setEmail(String email) {
  146. this.email = email;
  147. }
  148. /**
  149. * Gets the bookmarkEntityCollection of this UserEntity.
  150. * @return the bookmarkEntityCollection
  151. */
  152. public Collection<BookmarkEntity> getBookmarkEntityCollection() {
  153. return this.bookmarkEntityCollection;
  154. }
  155. /**
  156. * Sets the bookmarkEntityCollection of this UserEntity to the specified value.
  157. * @param bookmarkEntityCollection the new bookmarkEntityCollection
  158. */
  159. public void setBookmarkEntityCollection(Collection<BookmarkEntity> bookmarkEntityCollection) {
  160. this.bookmarkEntityCollection = bookmarkEntityCollection;
  161. }
  162. /**
  163. * Returns a hash code value for the object. This implementation computes
  164. * a hash code value based on the id fields in this object.
  165. * @return a hash code value for this object.
  166. */
  167. @Override
  168. public int hashCode() {
  169. int hash = 0;
  170. hash += (this.userid != null ? this.userid.hashCode() : 0);
  171. return hash;
  172. }
  173. /**
  174. * Determines whether another object is equal to this UserEntity. The result is
  175. * <code>true</code> if and only if the argument is not null and is a UserEntity object that
  176. * has the same id field values as this object.
  177. * @param object the reference object with which to compare
  178. * @return <code>true</code> if this object is the same as the argument;
  179. * <code>false</code> otherwise.
  180. */
  181. @Override
  182. public boolean equals(Object object) {
  183. // TODO: Warning - this method won't work in the case the id fields are not set
  184. if (!(object instanceof UserEntity)) {
  185. return false;
  186. }
  187. UserEntity other = (UserEntity)object;
  188. if (this.userid != other.userid && (this.userid == null || !this.userid.equals(other.userid))) return false;
  189. return true;
  190. }
  191. /**
  192. * Returns a string representation of the object. This implementation constructs
  193. * that representation based on the id fields.
  194. * @return a string representation of the object.
  195. */
  196. @Override
  197. public String toString() {
  198. return "com.sun.jersey.samples.bookmark.entities.UserEntity[userid=" + userid + "]";
  199. }
  200. }