I have parent object with lots of child objects so cant use EAGER. I've tried multiple styles to get all the child objects of parent, but the below size code, and everything else i've tried throws
failed to lazily initialize a collection of role xxxx, could not initialize proxy - no Session
How do i initialize all the child objects ? do i really need to make another query for all of them. Seems kinda stupid.
@Transactional
public List<XXX> findYYYinXXX(Long id) {
List<XXX> list = xxxRepo.findYYY(id);
for (XXX p : list){
p.getChild().size();
}
return list;
}
Hibernate.initialize(p.getChild); used inside for loop also throws the same error