@Audited
in my entities; revinfo
;I can filter audited data with user id, entity class, min and max date, using:
public <T extends BaseModel> List<Object[]> buscar(Class<T> clazz, Usuario usuario, java.util.Date inicio, java.util.Date fim){
GregorianCalendar novo = new GregorianCalendar();
novo.setTime(fim);
novo.add(Calendar.DAY_OF_MONTH, 1);
AuditReader reader = AuditReaderFactory.get(getEm());
return reader.createQuery()
.forRevisionsOfEntity(clazz, false, true)
.add(AuditEntity.revisionProperty("usuario")
.eq(usuario))
.add(AuditEntity.revisionProperty("revtstmp")
.between(inicio.getTime(), novo.getTime().getTime()))
.addOrder(AuditEntity.property("id")
.asc())
.getResultList();
}
But all relationships are lazy, including the @ManyToOne
.
I found many post about problems with @OneToMany
, but this is not the case
What can I do to access these properties?
PS: I tried, but could not highlight the code.
All relations in the objects returned by Envers are lazy, regardless if it's a one-to-many or many-to-one.
In an object, to access the related object's properties just call the getter :)
In a query, it's not possible. Joins are not supported, also regardless of the relation type. You can only constraint the id of the related entity, but not its properties.