Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate returns List with NULL

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi. I am getting a result from hibernate but the List object has null values on it.

Any ideas of the reason?


Thanks!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
It is lazy loaded?

Mark
 
Jazzy Sanchez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Yes it is.
 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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:

 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.

Mark
 
Jazzy Sanchez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am sorry. It is NOT Lazy Loading. It is not recommended to have a eager loading?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.

not sure if that helps you out or not.

felt pretty foolish when I figured it out.
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I have the same problem. I removed the index property but there's an xml error.

Guys please help.

Thanks!
 
Erap Estrada
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
here's the mapping in parent

<list name="reviews">
<key column="member_id"/>
<index column="review_id"/>
<one-to-many class="Review" />
</list>

Here`s the mapping in child

<many-to-one
name="member"
class="Member"
column="member_id" not-null="true"/>
[ October 02, 2007: Message edited by: Erap Estrada ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Erap, I am sorry, I am not sure what your issue is right now, because of it being posted in the context of this older thread.

Can you create a new Thread for your issue and please post the problem you are having?

Thanks

Mark
 
    Bookmark Topic Watch Topic
  • New Topic