Dear Alesinskyy: you don't get my point here. I expect Adam Warski to reply.
I get your point perfectly - you are afraid of joins - without any proof that this join would affect your performance noticeably.
It defintely would be good to make an API improvement suggested by you - but is this improvement of any priority is quite different matter.
That's true, in essence the join is not needed, but there's no other way to do it right now. I'm open to propositions on an extensions to the API and, of course, patches/pull requests
Adam
Hi Adam,
the solution you offer is also problematic. In my case I want to query forEntitiesAtRevision and want to have the entities and the revision (like the list of Object[] result of forRevisionsOfEntity). With the solution you proposed I would have to do the forEntitiesAtRevision query first and then a forRevisionsOfEntity query with each result. But for this second query I have to know how to get the id of an entity in the result.
AuditQuery q = AuditReaderFactory.get(em).createQuery()
.forEntitiesAtRevision(entityClass, revisionNumber)
.add(AuditEntity.relatedId(relatedEntityName).eq(relatedEntityId));
List<A> results = q.getResultList();
for (A result : results) {
List secondResults = AuditReaderFactory.get(em).createQuery()
.forRevisionsOfEntity(entityClass, false, true)
.add(AuditEntity.id().eq(result.getId())) // <-- impossible, since we don't know what A is
...
}
Is there a way to get the Revision Information for an entity by only giving the entity to envers? Like AuditReaderFactory.get(em).findRevisionForEntity(Entity e)?
Hmm no, you need to know the revision entity.
Well that's a limitation of the query API, true - please create a feature request.
Adam