I am trying to create a new database entry using Springboot hibernate and when I make the post request I get a 500 Internal Server Error on post man that says I have a stack over flow issue.
@Data @Entity public class AppUser { @GeneratedValue @Id private Integer userId; private String username; private String password; @OneToMany(mappedBy = "appUser") @ToString.Exclude private List userStrategies; @Builder public AppUser(String username, String password) { this.username = username; this.password = password; } public AppUser(){} } @Entity @Data public class Game { @GeneratedValue @Id private Integer gameId; private String gameName; private String gameDescription; @OneToMany(mappedBy = "game") @ToString.Exclude private List gameStrategies; public Game(){} @Builder public Game(String gameName, String gameDescription) { this.gameName = gameName; this.gameDescription = gameDescription; } } @Entity @Data public class Strategy { @GeneratedValue @Id private Integer id; private String strategyName; private String strategyDescription; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(referencedColumnName = "userId") @ToString.Exclude private AppUser appUser; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(referencedColumnName ="gameId") @ToString.Exclude private Game game; public Strategy(){} @Builder public Strategy(String strategyName, String strategyDescription, Game game, AppUser appUser) { this.strategyName = strategyName; this.strategyDescription = strategyDescription; this.appUser = appUser; this.game = game; } } @Service public class StrategyService { @Autowired private GameRepository gameRepository; @Autowired private AppUserRepository userRepository; @Autowired private StrategyRepository strategyRepository; public Strategy creatStrategy(Strategy strategy, Integer userId, Integer gameId){ Game game = gameRepository.findById(gameId).get(); AppUser user = userRepository.findById(userId).get(); Strategy newStrategy = Strategy.builder() .strategyDescription(strategy.getStrategyDescription()) .strategyName(strategy.getStrategyName()) .game(game) .appUser(user) .build(); strategyRepository.save(newStrategy); return newStrategy; } } @RestController public class StrategyController { @Autowired private StrategyRepository strategyRepository; @PostMapping("/strategy/user/{userId}/game/{gameId}") public Strategy creatStrategy( @RequestBody Strategy strategy, @PathVariable Integer userId, @PathVariable Integer gameId ){ Strategy newStrategy= creatStrategy(strategy, userId, gameId); return newStrategy; } } I tried using the @ToString.Exclude and @JsonIgnoreProperties(value = {"gameStrategies", "handler","hibernateLazyInitializer"}, allowSetters = true) on all the relationships that are joining but to no avail.

Источник: https://stackoverflow.com/questions/780 ... d-springbo