Retrieving

Description

For the following mapping:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 public class AnEntity extends HibernatePersistedObject { @Id @GeneratedValue private Long id; @OneToOne(optional=false,mappedBy="anEntity") private TargetEntity target; } public class TargetEntity { @Id @GeneratedValue private Long id; @ManyToOne private AnEntity anEntity; }

and the following query:

1 2 3 4 AuditReaderFactory.get(em).createQuery(). forRevisionsOfEntity(AnEntity.class,false,false). add(AuditEntity.id().eq(id)).addOrder(AuditEntity.revisionNumber().desc()). setMaxResults(1).getSingleResult()

I get an NPE because the there is no EntityConfiguration for TargetEntity, as it is not audited:

1 2 3 4 5 6 7 8 java.lang.NullPointerException at org.hibernate.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:81) at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:108) at org.hibernate.envers.entities.mapper.relation.OneToOneNotOwningMapper.mapToEntityFromMap(OneToOneNotOwningMapper.java:82) at org.hibernate.envers.entities.mapper.MultiPropertyMapper.mapToEntityFromMap(MultiPropertyMapper.java:118) at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:100) at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:135) at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:108)

Environment

None

Status

Assignee

Lukasz Antoniak

Reporter

ClintC

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.11
5.2.6
5.1.3
3.6.5

Priority

Major
Configure