Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the index for in hibernate List collection?

 
jianming chen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In hibernate collection, I like to use list, because it looks have perfect match with Java List. But it requires a index element. I don't really understand why it is a mandatory element? In Java List, it has an index, but you don't need to specify index when you insert an object into the list.

<list name="students">
<index name="stno"/>
<key column="id"/>
<one-to-many class="Student"/>
</list>
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lists are ordered: "index" is there to provide a way for Hibernate to maintain list order.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!