Guest User

Untitled

a guest
Mar 19th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.sample.scrumboard.models.User_$$_jvsta02_1["handler"])
  2.  
  3. @RestController
  4. @RequestMapping(path="/user")
  5. @JsonIgnoreProperties(ignoreUnknown = true)
  6. public class UserRestController {
  7.  
  8. private UserRepository repository;
  9.  
  10. @Autowired
  11. public UserRestController(UserRepository repository){
  12. this.repository = repository;
  13. }
  14.  
  15. @GetMapping(value = "/list")
  16. public List<User> getUsers(){
  17. return repository.findAll();
  18. }
  19.  
  20. @GetMapping(value = "/{id}")
  21. public @ResponseBody User getUserById(@PathVariable Long id, User user){
  22. user = repository.getOne(id);
  23. return user;
  24. }
  25. }
  26.  
  27. @Entity
  28. public class User {
  29.  
  30. @Id
  31. @GeneratedValue(strategy = GenerationType.IDENTITY)
  32. @Column(name = "userId", nullable = false, updatable = false)
  33. private Long id;
  34.  
  35. @NotNull
  36. @Size(min=2, max=20)
  37. private String firstName;
  38.  
  39. @NotNull
  40. @Size(min=2, max=30)
  41. private String lastName;
  42.  
  43. @NotNull
  44. @Size(min=2, max=20)
  45. private String userName;
  46.  
  47. @NotNull
  48. @Size(min=2, max=30)
  49. private String passWord;
  50.  
  51. @NotNull
  52. @Email
  53. private String email;
  54.  
  55. //the mappedBy element must be used to specify the relationship field or property of the entity that is the owner of the relationship
  56. @OneToMany(mappedBy = "owner", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  57. @JsonIgnore
  58. private List<UserStory> userStoryList;
  59.  
  60. public User() {
  61. }
  62.  
  63. public User(String firstName, String lastName, String userName, String passWord, String email) {
  64. this.firstName = firstName;
  65. this.lastName = lastName;
  66. this.userName = userName;
  67. this.passWord = passWord;
  68. this.email = email;
  69. }
  70.  
  71. @Override
  72. public String toString() {
  73. return "User{" +
  74. "id=" + id +
  75. ", firstName='" + firstName + ''' +
  76. ", lastName='" + lastName + ''' +
  77. ", userName='" + userName + ''' +
  78. ", passWord='" + passWord + ''' +
  79. ", email='" + email + ''' +
  80. '}';
  81. }
  82.  
  83. public Long getId() {
  84. return id;
  85. }
  86.  
  87. public void setId(Long id) {
  88. this.id = id;
  89. }
  90.  
  91. public String getFirstName() {
  92. return firstName;
  93. }
  94.  
  95. public void setFirstName(String firstName) {
  96. this.firstName = firstName;
  97. }
  98.  
  99. public String getLastName() {
  100. return lastName;
  101. }
  102.  
  103. public void setLastName(String lastName) {
  104. this.lastName = lastName;
  105. }
  106.  
  107. public String getUserName() {
  108. return userName;
  109. }
  110.  
  111. public void setUserName(String userName) {
  112. this.userName = userName;
  113. }
  114.  
  115. public String getPassWord() {
  116. return passWord;
  117. }
  118.  
  119. public void setPassWord(String passWord) {
  120. this.passWord = passWord;
  121. }
  122.  
  123. public String getEmail() {
  124. return email;
  125. }
  126.  
  127. public void setEmail(String email) {
  128. this.email = email;
  129. }
  130.  
  131. public List<UserStory> getUserStoryList() {
  132. return userStoryList;
  133. }
  134.  
  135. public void setUserStoryList(List<UserStory> userStoryList) {
  136. this.userStoryList = userStoryList;
  137. }
  138. }
Add Comment
Please, Sign In to add comment