I'm using Spring data
which is easy to use but i can't control it because i got error there
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: entity.Qualite.fonctions, could not initialize proxy - no Session
I know FetchType.EAGER
will work but i want keep it lazy.
so how can i control the session in spring data
@RequestMapping(value="/loadfonction")
public @ResponseBody
Set<Fonction> loadfonction(Map<String, Object> model, HttpServletRequest request) {
Set<Fonction> fonctions = qualiteRepo.findOne(Integer.valueOf(request.getParameter("idquality"))).getFonctions();
System.out.println(fonctions.size());
return fonctions;
}
I even try @Transactional annotation but it didn't work:
@Transactional
@RequestMapping(value="/loadfonction")