making figuring out the audit tables' column names without a formal API pretty error prone.
I completely understand the concern. As of Hibernate 5.x however, that information can be obtained through a formal API called EntityPersister. I would suggest you take a look at these two methods in particular and see if they'll satisfy your requirements:
String[] getPropertyNames();
public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException;
For example, for something like an @Embeddable mapping you'd supply the embeddable's property name to #toColumns and it would return you a list of all the columns the property has mapped; very straight forward. Either way, I'm leaving this open for us to consider as we move forward. For now, feel free to let me know if you run into any problems with the above suggestion for your use case. If it does work, then at least I have an idea of how to model the contracts for Envers when we get to that point. |