store an ORDERED collection from java to DB table
- if order in java is b1,b2,b3 then the entries in DB will be in the same order ( rownum wise ) on doing session.save(student) , right ?
- if order in java is b3,b2,b1 then the entries in DB will be in the same order ( rownum wise ) on doing session.save(student) , right ?
First of all the words sorted and ordered mean 2 different things when we are talking about Hibernate persistent collections. Sorted means sorted in memory using a Java comparator, while ordered is done at the database level using an SQL query with an order by clause. In this case I think you meant store a SORTED collection.
Different collection types are wrapped by different hibernate implementations. For example for a List with no ordered annotations a bag implementation will be used and order will be ignored. Also depending on your id generation strategy the consecutive rownum assumption may be faulty as well.