我们正在使用Envers审核表。我们正在使用Envers的AuditReader获得更改的历史记录。
数据已正确存储在数据库(表和审计表)中。
我们这样检索审核数据
public List<D> findAlleHistoriek(@Nonnull String erkenningsDossierId) {
List<D> erkenningsDossiers = new ArrayList<>();
List<Number> revisionNumbers = auditReader.getRevisions(ErkenningsDossier.class, erkenningsDossierId);
for (Number rev : revisionNumbers) {
// -- exception occurs here:
ErkenningsDossier dossier = auditReader.find(ErkenningsDossier.class, erkenningsDossierId, rev);
// --
erkenningsDossiers.add((D) dossier);
}
return erkenningsDossiers;
}
然后我们得到这个异常:
org.hibernate.HibernateException: HHH000143: Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity:
be.vaph.sparta.services.actoren.maatschappelijkerol.erkendemaatschappelijkerol.ErkendeMaatschappelijkeRol. Private constructors don't work with runtime proxies!
知道我们在做什么错吗?
我相信,这些是我们数据模型中最相关的部分:
@Audited
@AuditTable(value = AUDIT_TABLE_NAME, schema = DatabaseConstanten.SCHEMA_ERK)
@Entity
@Table(name = TABLE_NAME, schema = DatabaseConstanten.SCHEMA_ERK)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "dossiertype")
@DiscriminatorOptions(force = true)
public abstract class ErkenningsDossier<T extends ErkendeMaatschappelijkeRol> extends VaphJpaPersistent<String> implements Serializable {
// ...
@ManyToOne(targetEntity = ErkendeMaatschappelijkeRol.class)
@JoinColumn(name = COLUMN_MRE_UUID, nullable = false, updatable = false)
@NotNull
@Audited(targetAuditMode = NOT_AUDITED)
private T activiteit;
// ...
}
@Audited
@Entity
public abstract class ErkenningsDossierMetPunten<T extends ErkendeMaatschappelijkeRol> extends ErkenningsDossier<T> {
// ...
}
@Audited
@EntityListeners({AuditingEntityListener.class})
@Entity
@DiscriminatorValue(ErkenningsDossierType.VZA_LABEL)
public class ErkenningsDossierVZA extends ErkenningsDossierMetPunten<VergundeZorgaanbieder> {
// ...
}
@Entity
@SecondaryTable(name = ErkendeMaatschappelijkeRol.TABLE_NAME, pkJoinColumns = {@PrimaryKeyJoinColumn(name = ErkendeMaatschappelijkeRol.PK_NAME)}, schema = DatabaseConstanten.SCHEMA_ACTOREN)
public abstract class ErkendeMaatschappelijkeRol extends MaatschappelijkeRol<Organisatie> {
// ...
}
@Entity
@DiscriminatorValue(RolTypeCode.VERGUNDE_ZORGAANBIEDER_CODE)
public class VergundeZorgaanbieder extends ErkendeMaatschappelijkeRol {
// ...
public VergundeZorgaanbieder() {
super(RolType.VERGUNDE_ZORGAANBIEDER);
}
}
stacktrace:
org.hibernate.HibernateException: HHH000143: Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity:
be.vaph.sparta.services.actoren.maatschappelijkerol.erkendemaatschappelijkerol.ErkendeMaatschappelijkeRol. Private constructors don't work with runtime proxies! at
org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyFactory.getProxy(ByteBuddyProxyFactory.java:97) at
org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:713) at
org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:4962) at
org.hibernate.envers.internal.entities.mapper.relation.ToOneEntityLoader.createProxy(ToOneEntityLoader.java:62) at
org.hibernate.envers.internal.entities.mapper.relation.ToOneEntityLoader.createProxyOrLoadImmediate(ToOneEntityLoader.java:85) at
org.hibernate.envers.internal.entities.mapper.relation.ToOneIdMapper.nullSafeMapToEntityFromMap(ToOneIdMapper.java:162) at
org.hibernate.envers.internal.entities.mapper.relation.AbstractToOneMapper.mapToEntityFromMap(AbstractToOneMapper.java:60) at
org.hibernate.envers.internal.entities.mapper.MultiPropertyMapper.mapToEntityFromMap(MultiPropertyMapper.java:209) at
org.hibernate.envers.internal.entities.mapper.SubclassPropertyMapper.mapToEntityFromMap(SubclassPropertyMapper.java:86) at
org.hibernate.envers.internal.entities.mapper.SubclassPropertyMapper.mapToEntityFromMap(SubclassPropertyMapper.java:86) at
org.hibernate.envers.internal.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:89) at
org.hibernate.envers.internal.entities.EntityInstantiator.addInstancesFromVersionsEntities(EntityInstantiator.java:153) at
org.hibernate.envers.query.internal.impl.AbstractAuditQuery.applyProjections(AbstractAuditQuery.java:341) at
org.hibernate.envers.query.internal.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:133) at
org.hibernate.envers.query.internal.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:116) at
org.hibernate.envers.internal.reader.AuditReaderImpl.find(AuditReaderImpl.java:121) at
org.hibernate.envers.internal.reader.AuditReaderImpl.find(AuditReaderImpl.java:94) at
org.hibernate.envers.internal.reader.AuditReaderImpl.find(AuditReaderImpl.java:88) at
be.vaph.sparta.erkenningen.erkenningsdossier.ErkenningsDossierServiceImpl.findAlleHistoriek(ErkenningsDossierServiceImpl.java:235) at
...