We're updating the issue view to help you get more done. 

Lazy Loading of audited entites with revision type 'delete'

Description

Two classes are given, and they are related via a OneToOne relationship:

@Audited
public class MyClass {
@OneToOne
@Cascade(value = CascadeType.ALL)
private MyOtherClass otherClass;
}

@Audited
public class MyOtherClass {
}

The property "org.hibernate.envers.store_data_at_delete" is set to true, and when auditquerying for the deleted objects and initiliazing the otherClass (an entity which is also deleted) property, and ObjectNotFoundExceptions is thrown. It seems that the proxies do not look for deleted entities, because the same query works fine for the entities of revision type 'ADD' and 'MOD'. The code of the query:

AuditQuery queryDeleted = reader.createQuery().forRevisionsOfEntity(
MyClass.class, false, true).add(
AuditEntity.revisionType().eq(RevisionType.DEL));
List queryResult = queryDeleted.getResultList();
List<MyClass> result = new ArrayList<MyClass>();
for (Object object : queryResult) {
Object[] oArray = (Object[]) object;
MyClass c = (MyClass) oArray[0];
Hibernate.initialize(c.getOtherClass());
}

Forum post with Adam Warski's response:
http://community.jboss.org/thread/160939?tstart=0

Environment

Hibernate 3.5.6, Oracle 10 DB

Status

Assignee

Lukasz Antoniak

Reporter

J

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

3.5.6

Priority

Major