| There are a couple problems when creating indexes for audited tables and the main problem is column order. Envers gathers all mapping metadata from ORM and generates a series of HBM XML mappings. The problem is this format doesn’t support dictating order of columns per index so you can easily run into a situation for any multi-column index that the order of the columns in the generated audit index likely may not appear in the same order as that of the main table, which can have performance degradation problems if built incorrectly. Is there a reason why doing this manually is a problem? We could investigate using the Auxiliary Database Objects mapping and attempt to define the index using the create and delete modes of operation when we build the HBM XML mapping. The one last standing concern will be that which is pointed out in https://hibernate.atlassian.net/browse/HHH-6035 which is handling naming of indexes since they must be uniquely named across databases. |