Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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"])
- @RestController
- @RequestMapping(path="/user")
- @JsonIgnoreProperties(ignoreUnknown = true)
- public class UserRestController {
- private UserRepository repository;
- @Autowired
- public UserRestController(UserRepository repository){
- this.repository = repository;
- }
- @GetMapping(value = "/list")
- public List<User> getUsers(){
- return repository.findAll();
- }
- @GetMapping(value = "/{id}")
- public @ResponseBody User getUserById(@PathVariable Long id, User user){
- user = repository.getOne(id);
- return user;
- }
- }
- @Entity
- public class User {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "userId", nullable = false, updatable = false)
- private Long id;
- @NotNull
- @Size(min=2, max=20)
- private String firstName;
- @NotNull
- @Size(min=2, max=30)
- private String lastName;
- @NotNull
- @Size(min=2, max=20)
- private String userName;
- @NotNull
- @Size(min=2, max=30)
- private String passWord;
- @NotNull
- @Email
- private String email;
- //the mappedBy element must be used to specify the relationship field or property of the entity that is the owner of the relationship
- @OneToMany(mappedBy = "owner", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
- @JsonIgnore
- private List<UserStory> userStoryList;
- public User() {
- }
- public User(String firstName, String lastName, String userName, String passWord, String email) {
- this.firstName = firstName;
- this.lastName = lastName;
- this.userName = userName;
- this.passWord = passWord;
- this.email = email;
- }
- @Override
- public String toString() {
- return "User{" +
- "id=" + id +
- ", firstName='" + firstName + ''' +
- ", lastName='" + lastName + ''' +
- ", userName='" + userName + ''' +
- ", passWord='" + passWord + ''' +
- ", email='" + email + ''' +
- '}';
- }
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- public String getFirstName() {
- return firstName;
- }
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
- public String getLastName() {
- return lastName;
- }
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String getPassWord() {
- return passWord;
- }
- public void setPassWord(String passWord) {
- this.passWord = passWord;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public List<UserStory> getUserStoryList() {
- return userStoryList;
- }
- public void setUserStoryList(List<UserStory> userStoryList) {
- this.userStoryList = userStoryList;
- }
- }
Add Comment
Please, Sign In to add comment