I’ve been fighting for the error not could initialize - no proxy for a long time, everything works fine with Eager.Fetch Therefore, such a question crept in.
Upd. I call in the controller to the method of this service.
@Service public class UserServiceImpl implements UserService { @Autowired private UserRepository repository; @Override public List<User> getAll() { return repository.findAll(); } } Here is my entity:
@Entity @Table(name = "users") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "login") private String login; @ManyToOne(fetch = FetchType.Lazy, cascade=CascadeType.MERGE) @JoinColumn(name = "id_city") private City city; ... } It gives an error that can not initialize the city - no Proxy.