79090972

Date: 2024-10-15 16:54:33
Score: 0.5
Natty:
Report link

You need to use @JsonManagedReference for the roles field in the AppUser entity and @JsonBackReference for the appUsers field in the Role entity. And most likely you also need to use @EntityGraph(attributePaths = "roles") when loading users to avoid LazyInitializationException, or you can just add fetch = FetchType.EAGER for the roles field.

Reasons:
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (0.5):
Posted by: Andrey Smelik