spring-projects/spring-framework — pull request #425 by fpavageau (2013-12-09 21:58:42+00:00)
Title: Sort the scanned Hibernate entities by name

When using AnnotationSessionFactoryBean.packagesToScan, the scan does
not find annotated classes in a specific or stable order. The order used
to add the classes to the configuration of the SessionFactory has a
direct impact on the SQL queries generated by Hibernate, so different
JVMs will generate queries that are equivalent but not equal:
- It's impossible to get aggregated statistics across instances
- It causes additional load for the database which has to parse
different queries

This is fixed by sorting the classes by fully qualified name, which
provides a stable order across runs. It only adds stability and
predictability, without changing the functionality.

Issue: [SPR-7742](https://jira.springsource.org/browse/SPR-7742)

I have signed and agree to the terms of the SpringSource Individual
Contributor License Agreement.