I'm seeing a serious performance issue with Hibernate and non-deterministic sql across jvms. I believe the issue is with the interaction of the LocalContainerEntityManagerFactoryBean and Hibernate generating table identifiers. The identifiers are assigned based on Entity load order and from sql I'm seeing generated I believe the Entities are loaded in a non-deterministic way as Spring scans them and passes them to Hibernate.

At this point it's just speculation because I don't have a good understanding of the interaction between the annotation scanning and the EntityManager. Can someone more familiar with the Entity scanning process confirm? or give me a general overview so I can troubleshoot further? I think what needs to happen is all Entities scanned and then sorted prior to creation to ensure all tables are created in the same order.

-Bill