Guest User

Untitled

a guest
Nov 10th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. @Entity
  2. @Table(name = "userEntity", schema = "public")
  3. public class UsersEntity implements java.io.Serializable{
  4. private Integer userId;
  5. private String name;
  6. private Integer date;
  7. private String username;
  8. private String phone;
  9. private String email;
  10. private String password;
  11. private String country;
  12. private Set<Stock> stock = new HashSet<Stock>(
  13. 0);
  14.  
  15. public UsersEntity() {
  16. }
  17.  
  18. public UsersEntity(Integer userId, String name, Integer date, String username,
  19. String phone, String email, String password, String country,
  20. Set<Stock> stock) {
  21. this.userId = userId;
  22. this.name = name;
  23. this.date = date;
  24. this.username = username;
  25. this.phone = phone;
  26. this.email = email;
  27. this.password = password;
  28. this.country = country;
  29. this.stock = stock;
  30. }
  31.  
  32. @Column(name = "name", nullable = true, length = 255)
  33. public String getName() {
  34. return name;
  35. }
  36.  
  37. public void setName(String name) {
  38. this.name = name;
  39. }
  40.  
  41. @Id
  42. @Column(name = "userId")
  43. @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "user_seq_gen")
  44. @SequenceGenerator(name = "user_seq_gen", sequenceName = "user_id_seq")
  45. public Integer getUserId() {
  46. return userId;
  47. }
  48.  
  49. public void setUserId(Integer userId) {
  50. this.userId = userId;
  51. }
  52.  
  53. @Column(name = "date", nullable = true, length = 255)
  54. public Integer getDate() {
  55. return date;
  56. }
  57.  
  58. public void setDate(Integer date) {
  59. this.date = date;
  60. }
  61.  
  62. @Column(name = "username", nullable = true, length = 255)
  63. public String getUsername() {
  64. return username;
  65. }
  66.  
  67. public void setUsername(String username) {
  68. this.username = username;
  69. }
  70.  
  71. @Column(name = "phone", nullable = true, length = 255)
  72. public String getPhone() {
  73. return phone;
  74. }
  75.  
  76. public void setPhone(String phone) {
  77. this.phone = phone;
  78. }
  79.  
  80. @Column(name = "email", nullable = true, length = 255)
  81. public String getEmail() {
  82. return email;
  83. }
  84.  
  85. public void setEmail(String email) {
  86. this.email = email;
  87. }
  88.  
  89. @Column(name = "password", nullable = true, length = 255)
  90. public String getPassword() {
  91. return password;
  92. }
  93.  
  94. public void setPassword(String password) {
  95. this.password = password;
  96. }
  97.  
  98. @Column(name = "country", nullable = true, length = 255)
  99. public String getCountry() {
  100. return country;
  101. }
  102.  
  103. public void setCountry(String country) {
  104. this.country = country;
  105. }
  106.  
  107. @OneToMany(fetch = FetchType.LAZY, mappedBy = "userEntity")
  108. public Set<Stock> getStock() {
  109. return this.stock;
  110. }
  111.  
  112. public void setStock(Set<Stock> stock) {
  113. this.stock = stock;
  114. }
  115.  
  116. @Entity
  117. @Table(name = "stock", schema = "public")
  118. public class Stock {
  119. private int id;
  120. private String description;
  121. private UsersEntity usersEntity;
  122.  
  123. public Stock() {
  124. }
  125.  
  126. public Stock(int id, String description) {
  127. this.id = id;
  128. this.description = description;
  129. }
  130.  
  131. @Id
  132. @GeneratedValue(strategy = IDENTITY)
  133. @Column(name = "id", unique = true, nullable = false)
  134. public int getId() {
  135. return id;
  136. }
  137.  
  138. public void setId(int id) {
  139. this.id = id;
  140. }
  141.  
  142. @Column(nullable = true, length = 255)
  143. public String getDescription() {
  144. return description;
  145. }
  146.  
  147. public void setDescription(String description) {
  148. this.description = description;
  149. }
  150.  
  151. @ManyToOne(fetch = FetchType.LAZY)
  152. @JoinColumn(name = "userId", nullable = false)
  153. public UsersEntity getUser() {
  154. return this.usersEntity;
  155. }
  156.  
  157. public void setUser(UsersEntity usersEntity) {
  158. this.usersEntity = usersEntity;
  159. }
  160.  
  161. <hibernate-configuration>
  162. <session-factory>
  163. <property name="hbm2ddl.auto">create</property>
  164. <property name="connection.url">jdbc:postgresql://localhost:5432/personal2</property>
  165. <property name="connection.username">postgres</property>
  166. <property name="connection.password">root</property>
  167. <property name="connection.driver_class">org.postgresql.Driver</property>
  168.  
  169. <mapping class="Entity.UsersEntity"/>
  170. <mapping class="Entity.Stock"/>
  171.  
  172. org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: Entity.Stock.userEntity in Entity.UsersEntity.stock
Add Comment
Please, Sign In to add comment