I've got a many-to-many relationship in my database and I'm using Hibernate to retrieve a single row from the left hand side of the relationship. I then just call the getter method to retrieve the associated right hand side of the relationship (lazy fetch).
As part of my work, I need to sort the right hand side "list" object by doing this:
Collections.sort(list);
When I'm done my work, I'm currently calling:
session.getTransaction().commitTransaction();
Even though I haven't actually changed anything in the database in terms of the data, I can see in the logs that some INSERT statements were triggered.
What should I be doing in this situation so that I could order the list without incurring a database hit?