I'm trying to add a join between two tables as I stated in this question: Adding table joins to existing project causes infinite recursion
However now I got a new error which states:
detached entity passed to persist: sample.todosapp.spring.domain.User] with root cause
When I try to call this code (this is modified method for POST in my REST controller):
@RequestMapping(method = POST)
@ResponseStatus(HttpStatus.CREATED)
public Callable<Todo> post(@RequestBody Todo todo) {
User u = userService.findBySso(SecurityContextHolder.getContext().getAuthentication().getName());
todo.setUser(u);
return () -> todoRepository.save(todo);
}
How do you add a join during POST?