• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the index for in hibernate List collection?  RSS feed

 
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!