HHH-6605: Fixing problems with lazy proxy initialization

This commit is contained in:
Adam Warski 2012-01-20 22:46:36 +01:00
parent 89bb7ec175
commit f434cd4311
2 changed files with 2 additions and 7 deletions

View File

@ -109,6 +109,8 @@ public abstract class BaseEnversEventListener implements EnversListener {
HibernateProxy hibernateProxy = (HibernateProxy) value;
toEntityName = session.bestGuessEntityName(value);
id = hibernateProxy.getHibernateLazyInitializer().getIdentifier();
// We've got to initialize the object from the proxy to later read its state.
value = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
} else {
toEntityName = session.guessEntityName(value);

View File

@ -55,7 +55,6 @@ public class CollectionChangeWorkUnit extends AbstractAuditWorkUnit implements A
public Map<String, Object> generateData(Object revisionData) {
fillDataWithId(data, revisionData);
resolveProxyIfNeeded();
Map<String, Object> preGenerateData = new HashMap<String, Object>(data);
verCfg.getEntCfg().get(getEntityName()).getPropertyMapper()
.mapToMapFromEntity(sessionImplementor, data, entity, null);
@ -67,12 +66,6 @@ public class CollectionChangeWorkUnit extends AbstractAuditWorkUnit implements A
return data;
}
private void resolveProxyIfNeeded() {
if (entity instanceof HibernateProxy) {
Tools.getTargetFromProxy(sessionImplementor.getFactory(), (HibernateProxy) entity);
}
}
public void mergeCollectionModifiedData(Map<String, Object> data) {
verCfg.getEntCfg().get(getEntityName()).getPropertyMapper()
.mapModifiedFlagsToMapForCollectionChange(