We are using Hibernate Envers and have the following situation:
A class BusinessObjectType
and a class Identity
with a reference to BusinessObjectType
:
@Entity
@Table( name = "ID_IDENTITY" )
@Audited
public class Identity {
@ManyToOne
@JoinColumn( name = "BO_TYPE_ID" )
@IndexColumn( name = "INDEX_BO_BO_TYPE" )
private BusinessObjectType businessObjectType;
[…]
}
We then query for all the version of Identity with:
AuditQuery auditQuery = auditReader.createQuery().forRevisionsOfEntity(
Identity.class,
false,
true );
auditQuery.add( AuditEntity.id().eq( dbid ) );
@SuppressWarnings( "unchecked" )
List< Object[]> history = (List< Object[]>) auditQuery.getResultList();
If the stored identity does not have a BusinessObjectType
(i.e., businessObjectType
is and was null) everything works like a charm.
If the identity had a businessObjectType != null
we get a "Javassist Enhancement failed" Exception:
Javassist Enhancement failed: ch.ethz.id.wai.baseclasses.BusinessObjectType
The error seems to be related to Envers trying to instantiate a BusinessObjectType but I don't really see what the problem could be (Hibernate has no problems with both objects if we don't use an AuditQuery).
The cause of the exception is
java.lang.InstantiationException: ch.ethz.id.wai.baseclasses.BusinessObjectType_$$_javassist_49
with no stack trace.
Any hint on what the problem could be?
This happens inside the following class JavassistLazyInitializer A Javassist-based lazy initializer proxy.
Without having a look at full source it is difficult to comment but you can try following options.
hibernate.bytecode.use_reflection_optimizer
property to falseLet us know if this helps