# Mapping Hibernate envers tables

**URL:** <https://discourse.hibernate.org/t/mapping-hibernate-envers-tables/10861>\
**Category:** Hibernate ORM\
**Created:** [January 9, 2025, 7:11am UTC](https://discourse.hibernate.org/t/mapping-hibernate-envers-tables/10861 "2025-01-09T07:11:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [January 9, 2025, 9:53am UTC](https://discourse.hibernate.org/t/mapping-hibernate-envers-tables/10861/2 "2025-01-09T09:53:34Z")

</div>

You can actually use audit entities in HQL, but the metamodel for the entities might be a bit non-obvious. Look up the metamodel for the fully qualified name of the entity class + `_AUD` to see what attributes you have available.

You can do something like the following for example:

```java
session.createQuery("select e, a from MyEntity e join my.company.MyEntity_AUD a on e.id = a.originalId.id", Object[].class)
.getResultList();

```

---

_[View the full topic](https://discourse.hibernate.org/t/mapping-hibernate-envers-tables/10861)._
