In that case you can initialize the List with a call like myList.size() or something like that. That would usually load the Collection from the database. Or, you can change the class mapping to make it eager loaded. With Annotations, you would write something like this:
I would probably not set the relationship to eager in the mapping, but set fetch modes in your Queries so that you can eager fetch what you need for the particular use case you are working on. But yes, when you need that list filled you can touch the list so to speak, or in your query that loads the data set that to fetch eager. But it must be within the context of a session or entityManager.
Joined: Apr 02, 2006
I am sorry. It is NOT Lazy Loading. It is not recommended to have a eager loading?
I had the same issue and just caught what my mistake was. I don't know if you're using the index column property or not, but I was. And with a list this was putting the objects in the precise index from the database...since my values were 1, 2, 3 the 0 index was null.