Right so i am working with hibernate gilead and gwt to persist my data on users and files of a website. my users have a list of file locations. i am using annotations to map my
Lazy means that the values of the collection are loaded from the database only when they are accessed. If at that time the Session
has been closed, the LazyInitializationException
is thrown, because the data cannot be fetched.
In your case I'd simply suggest adding an eager fetch type to the association:
@ManyToMany(cascade = CascadeType.ALL, fetchType=FetchType.EAGER)
This will load the fileLocations
when the entity is loaded and no lazy loading will be needed.
A common solution is to use OpenSessionInView, but it may not always work with GWT, becaucse the client is remote and the session cannot be opened there.
So you are going to have some problems with lazy initialization. You can search around for related questions, there are a few - this and this for example.
This exception means that the FileLocations association is not yet loaded and you are trying to access it. There is no session opened, and there is no way to load the association. This is the LazyInitializationException.
Edit: Read Bozho's post for the solution.