When I get Set users out of the database using the hibernate, they always come in a different order, what is the reason for this and is it possible to somehow control without using sorting after receiving?

  • 2
    Set stores data unsorted. So either you need to sort them either after receiving them or in the database you should make the request so that the answer is either sorted or not. Set - Yuriy SPb
  • And which method is considered more successful? - GermanSevostyanov
  • on the idea bd optimizes requests for sorting or not critical? - GermanSevostyanov
  • What method is better - I do not know. If you have relatively little data (~ 1000), then I think the difference will not be special. But I would try to force the database to return the sorted data, because, I think, it will be more productive a little bit like that. - Yuriy SPb
  • 3
    Use the List. In the ORDER BY query on the corresponding field. In addition, the ORM can do it themselves, with the inclusion of special options. For example, in JPA there is a summary @OrderBy () applied to lists - Sergey

0