I am using envers to audit my entities. My code looks somewhat like this
@Audited( targetAuditMode = RelationTargetAuditMode.NOT_AUDITED )
@AuditOverride( forClass = Task.class, isAudited = true )
public class Job extends Task
{...}
@Inheritance( strategy = InheritanceType.JOINED )
@Audited( targetAuditMode = RelationTargetAuditMode.NOT_AUDITED )
public class Task
{
...
@ManyToOne( fetch = FetchType.LAZY )
@LazyToOne( value = LazyToOneOption.NO_PROXY )
@Fetch( value = FetchMode.SELECT )
@JoinColumn( nam = "id_util" )
@Audited( targetAuditMode = RelationTargetAuditMode.AUDITED )
private Utility utility;
}
@Entity
@DynamicInsert
@DynamicUpdate
@Audited( targetAuditMode = RelationTargetAuditMode.NOT_AUDITED )
public class Utility
{
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append( this.getClass().getName() ).append( "@" ).append( getId() );
builder.append( "[" );
appendAttributeValues( builder );
builder.append( "]" );
return builder.toString();
}
public Long getId()
{
return id;
}
}
When I try to fetch the revisions of a certain job
entity, the field utility
is not loaded correctly. Instead, hibernate gives a
Method threw 'org.hibernate.exception.GenericJDBCException' exception. Cannot evaluate Utility$HibernateProxy$9GVDBIUC.toString()
The rest of the entity revisions which consists of strings and numbers is loaded just fine. I also don't get this error when auditing and querying other entities which do not have an inheritance structure.
The _aud
tables for the entities Job
, Task
and Utility
are all filled correctly. What might be causing this error?