In 5.2 it was possibile to get the EntityType of an Envers entity, which is useful to inspect its attributes or pass it to other tools such as Blaze Persistence and create complex queries not provided by Envers. For example:
SessionFactoryImplementor session = em.unwrap(SessionImplementor.class).getSessionFactory();
MetamodelImplementor metamodel = session.getMetamodel();
String entityName = metamodel.entityPersister(MyEntity.class).getEntityName();
EnversService envers = session.getServiceRegistry().getService(EnversService.class);
String auditEntityName = envers.getAuditEntitiesConfiguration().getAuditEntityName(entityName);
EntityType entityType = metamodel.entity(auditEntityName);
In 5.3. the same code returns a null EntityType. |