Can i use the fetchgraph with an envers audit query?

in the standard hibernate queries one can apply a fetchgraph which joins related entities.
How can i do that with the AuditQuery? I could not find an API for that.

You can use HQL to also query audit data. Usually, the entity name for audit entities is the fully qualified class name + _AUD suffix e.g.

select e
from MyEntity e join com.mycompany.MyEntity_AUD eAud on =

I am already aware of that possibility.
I was just wondering if there is an easier way, especially since i would need to apply the restriction on the revision manually in the hql

There is no easier way AFAIK.

I have just played around with the hql a little bit.
But it seems like hibernate can’t map the things correctly because the envers metamodel tables do not include the ToOne Mappings and so on.

E.g. when I try something like:
SELECT b FROM BaseEntity_AUD b JOIN FETCH BaseEntityExtraInfo_AUD e ON e.originalId.identifer = b.extraInfo_identifier
with entityManager.createQuery(hql, BaseEntity.class).getResultList() hibernate returns a Map<String, Object> which only includes the properties of BaseEntity and “extraInfo_identifier”…

I’m actually surprised that this HQL query doesn’t blow up. You can’t fetch for entity joins. Only association joins can do that.

I don’t know how the Envers model looks like in your case, but since this is a dynamic model, it will always return a Map<String, Object>. If the model has an association mapping, then you could join fetch that, but otherwise you’d have to just select that other entity you joined.

Are there any plans on adding those association mappings to the envers model?

The core Hibernate ORM team does not have any plans to add new features to Hibernate Envers at this time. Maybe after Hibernate ORM 7.0 is released and we build Envers on a different foundation, we could consider adding new features.