Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic