HHH-6605: Fixing problems with lazy proxy initialization
This commit is contained in:
parent
89bb7ec175
commit
f434cd4311
|
@ -109,6 +109,8 @@ public abstract class BaseEnversEventListener implements EnversListener {
|
||||||
HibernateProxy hibernateProxy = (HibernateProxy) value;
|
HibernateProxy hibernateProxy = (HibernateProxy) value;
|
||||||
toEntityName = session.bestGuessEntityName(value);
|
toEntityName = session.bestGuessEntityName(value);
|
||||||
id = hibernateProxy.getHibernateLazyInitializer().getIdentifier();
|
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 {
|
} else {
|
||||||
toEntityName = session.guessEntityName(value);
|
toEntityName = session.guessEntityName(value);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class CollectionChangeWorkUnit extends AbstractAuditWorkUnit implements A
|
||||||
|
|
||||||
public Map<String, Object> generateData(Object revisionData) {
|
public Map<String, Object> generateData(Object revisionData) {
|
||||||
fillDataWithId(data, revisionData);
|
fillDataWithId(data, revisionData);
|
||||||
resolveProxyIfNeeded();
|
|
||||||
Map<String, Object> preGenerateData = new HashMap<String, Object>(data);
|
Map<String, Object> preGenerateData = new HashMap<String, Object>(data);
|
||||||
verCfg.getEntCfg().get(getEntityName()).getPropertyMapper()
|
verCfg.getEntCfg().get(getEntityName()).getPropertyMapper()
|
||||||
.mapToMapFromEntity(sessionImplementor, data, entity, null);
|
.mapToMapFromEntity(sessionImplementor, data, entity, null);
|
||||||
|
@ -67,12 +66,6 @@ public class CollectionChangeWorkUnit extends AbstractAuditWorkUnit implements A
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolveProxyIfNeeded() {
|
|
||||||
if (entity instanceof HibernateProxy) {
|
|
||||||
Tools.getTargetFromProxy(sessionImplementor.getFactory(), (HibernateProxy) entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mergeCollectionModifiedData(Map<String, Object> data) {
|
public void mergeCollectionModifiedData(Map<String, Object> data) {
|
||||||
verCfg.getEntCfg().get(getEntityName()).getPropertyMapper()
|
verCfg.getEntCfg().get(getEntityName()).getPropertyMapper()
|
||||||
.mapModifiedFlagsToMapForCollectionChange(
|
.mapModifiedFlagsToMapForCollectionChange(
|
||||||
|
|
Loading…
Reference in New Issue