Hi, i am having some problems with retrieving my entity. The error i got is:
Exception Description: An attempt was made to traverse a relationship using indirection that had a null Session. This often occurs when an entity with an uninstantiated LAZY relationship is serialized and that lazy relationship is traversed after serialization. To avoid this issue, instantiate the LAZY relationship prior to serialization.
Part of the session bean code:
Query q = em.createQuery("SELECT DISTINCT subProgT FROM SubTrainingProgTemplate subProgT " +
"LEFT JOIN FETCH subProgT.trainingActivityTemplates " +
"WHERE subProgT.id =:subProgTempId");
Well, i try to retrieve the entity in the
servlet where i do this:
System.out.println("Size: " + xxx.getSubTrainingProgTemplate(new Long(xx)).getTrainingActivityTemplates().size());
Even with the use of Left Join Fetch, i still encounter the error above, which doesn't really make sense to me.
However, by adding 1 more line of code in the session bean:
xx.getTrainingActivityTemplates().size();
**The error somehow vanish, and i was able to retrieve the size value in servlet. I don't know what's happening, can anyone help me here? Thanks!