Starting with hibernate-annotations-3.2.0.GA, the schema SQL file that is generated via the Configuration, AnnotationConfiguration, Table, etc. classes arbitrarily reorders the foreign key columns (in the generated create table statements).
I've tracked this down to a Comparator class created in the AnnotationConfiguration.processFkSecondPassInOrder() method. This Comparator uses the hashcode value against instances of the FkSecondPass.java class. Unfortunately, FkSecondPass,java doesn't implement hashCode, so the ordering of foreign key columns changes for one execution of the generate schema process to another.
This isn't really a bug, however, our build process takes a checksum of the file generated by this process, as well as 4 or 5 other files we generate with additional constraints, indexes, etc. With the foreign key columns changing order all the time, this checksum is constantly changing, forcing our developers to drop their schema, test data, etc., then recreate the schema, seed data, etc., and with well over 400 tables, 4000 constraints, tons of seed data, tests that need to execute to re-build some binary information, etc., the turn around time for recreating the schema is about 20 minutes.
Anyway, I've added simple hashCode() and equals() methods to the FkSecondPass.java class, and this problem went away. The hashcode and equals includes the FkSecondPass.java class' Ejb3JoinColumns, so the hashcode is deterministic.
If this change or something similar could be incorporated into a future release of the annotations project, that would be great.
|