1

For example I have two entities:

@Entity
@Audited
@Table(....
public class Worker
{
    private Long id;
    private String name ;
}

@Entity
@Audited
@Table(....
public class Department
{
    private Long id;
    private String departmentName;
    private Worker worker;

}

I want to display the following data for Department:

| departmentName | name (from fetched entityworker) |

When using AuditQuery to get audit information for entity Department, is it possible to fetch the entity Worker to display name value for more human readable display?

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
danizmax
  • 2,446
  • 2
  • 32
  • 41

2 Answers2

1

This feature is not supported, so you'll have to use a native query and join the actual database tables.

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
0

EAGER loading is not supported by envers, all association can only be lazy loaded. An alternative solution to doing joins by hand, is initializing lazy fields of an entity.

My solution to this problem was to go through all fields using java reflection (see), finding proxies by using Hibernate.isInitialized(...) and initializing them with Hibernate.initialize(...).

Community
  • 1
  • 1
danizmax
  • 2,446
  • 2
  • 32
  • 41