I assume that you have an association to another entity in the one that throws the lazy error.
The problem is that the entities in the associated collection only have their ID value present. This is because the default fetch type is LAZY. When you try to access one of the associated objects your app blows an error about lazy initialization because you are in a new session and this session knows nothing about the association.
To fix this the original association must be marked as fetch type EAGER but BE CAREFUL! This will cause all entites in the associated collection to be completely filled in. Monitor the SQL generated by the association and make sure that an outer join is generated. You do not want a SQL query generated for each of the associated objects!
Hope this helps.
Joined: Sep 25, 2008
did and now it's fine. Thanks.
subject: LazyInitializationException: Failed to lazily initialize a collectio