• Post Reply 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

List that contains null values

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there. I am retrieving a List through Hibernate. The problem is the returned List contains null values. So when I iterate through it, I also ran to those null values. Objects are apart from each other in the List.

Here's the mapping for the parent class Member
<list name="reviews">
<key column="member_id"/>
<index column="review_id"/>
<one-to-many class="Review" />
</list>

Here's the mapping for the child class Reviews
<many-to-one
name="member"
class="Member"
column="member_id" not-null="true"/>

Basically, each Member has multiple reviews.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, based on your mapping, Hibernate does not know that those two mappings are mapping the same relationship. You need an inverse="true" in there.

Mark
 
Erap Estrada
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I already set inverse to true for both. Any more ideas what causing this?

I read somewhere that causing it could be the index column but did not specify how to resolve it.

I am starting to feel hibernate is complicated. All I want is "Member has multiple Reviews" and a "Review has a Member".

Thanks in advance!
[ October 03, 2007: Message edited by: Erap Estrada ]
 
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Erap Estrada:
I already set inverse to true for both.



Just one, please
 
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:
  • Quote
  • Report post to moderator

Originally posted by Erap Estrada:
I already set inverse to true for both. Any more ideas what causing this?

I read somewhere that causing it could be the index column but did not specify how to resolve it.

I am starting to feel hibernate is complicated. All I want is "Member has multiple Reviews" and a "Review has a Member".

Thanks in advance!

[ October 03, 2007: Message edited by: Erap Estrada ]



Hibernate has a good sized learning curve because it is extremely feature rich, and allows you to really set things up exactly how you want it, and with features to make it really fast.

With that in mind, for a simple one to many, try just using a Set first instead of trying a List, since the index-column is there because Lists needing an order.

Try a Set and see how that works for you.

Mark
 
Erap Estrada
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I apologize if I sound desperate. I temporarily resolve it by creating a utility class to clear the null values in the List.

But I will try to use Set instead and I'll post the result of it here.

Again, thank you so much guys.
 
Erap Estrada
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Set resolved the issue. Thank you so much!
reply
    Bookmark Topic Watch Topic
  • New Topic