Currently, the method org.hibernate.envers.AuditReader.isEntityClassAudited can be used to check if an entity is audited.
It would be nice to have access to all audited entites through the AuditReader.
Here's some workarounds
By hibernate's Entity Manager:
Based on the workarounds you have shown, you illustrate that only the class-name for managed entity types that are audited suffices. But what your code does not illustrate is the purpose behind needing these values and that is what I am interested in having a better understanding for.
Are you trying to gain further details from EnversService by fetching an EntityConfiguration object?
Are you inspecting the actual EntityType's JPA metamodel?
Having a bit more depth as to why you need this can go a long way in making sure that we provide an adequate API for a user's needs that goes beyond simply just exposing some collection of Class<?> objects or String class-names.
First of all thank you for your response.
We are trying to get all audited class in order to present them to the user. With this list, the user can select one or more class to see all changes of all objets of this these class
I personally think there may be some value in exposing a run-time model that users can inspect. The only concern I have presently is that EntityConfiguration is mutable and I'd ideally prefer this run-time model that we expose to be immutable. There is a fair bit of internal changes that are planned throughout the 6.x release stream, so adding this as a part of that rework should be quite easy.
If I had to suggest either of your workarounds, it would be the one based on the JPA metamodel. It will remain portable across both major versions and adheres to a public API without accessing any internals of either ORM or Envers. I can tell you that the reflection approach using EnversServiceImpl will not be portable to 6.x at all.