hantsy/angularjs-springmvc-sample-boot

Error in BlogService.java savePost method

compumike08 opened this issue · 1 comments

In the file https://github.com/hantsy/angularjs-springmvc-sample-boot/blob/master/src/main/java/com/hantsylabs/restexample/springmvc/service/BlogService.java, in the savePost method, on line 68, you currently have the code:

return DTOUtils.map(post, PostDetails.class);

That should actually be:

return DTOUtils.map(saved, PostDetails.class);

That line (line 68) in the savePost method returns the PostDetails object mapped by the Post object which was returned from the save(post) call earlier (line 62), which created a new Post in the database and returned the newly created Post object to be stored in the Post saved variable. That saved variable should be what is mapped to PostDetails.class and returned on line 68, not the original post variable.

@hantsy

@compumike08 Thanks for your contribution, I have fixed it and added test codes for it.