Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Return real entity instead of proxy where available in session.

This matches gorm-hibernate behaviour.
  • Loading branch information...
commit bc369c06c99697dd981262cb7458846fc2b288ab 1 parent 6726d6c
@tomwidmer tomwidmer authored
View
8 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/core/AbstractSession.java
@@ -516,7 +516,13 @@ public Object proxy(Class type, Serializable key) {
"]. The class [" + type.getName() + "] is not a known persistent type.");
}
- return persister.proxy(key);
+ // only return proxy if real instance is not available.
+ Object o = getInstanceCache(type).get(key);
+ if (o == null) {
+ o = persister.proxy(key);
+ }
+
+ return o;
}
public void lock(Object o) {
View
11 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/engine/NativeEntryEntityPersister.java
@@ -483,13 +483,10 @@ else if (tmp != null && !prop.getType().isInstance(tmp)) {
boolean isLazy = isLazyAssociation(associationPropertyMapping);
final Class propType = prop.getType();
- if (isLazy) {
- Object proxy = getProxyFactory().createProxy(session, propType, associationKey);
- ea.setProperty(prop.getName(), proxy);
- }
- else {
- ea.setProperty(prop.getName(), session.retrieve(propType, associationKey));
- }
+ Object value = isLazy ?
+ session.proxy(propType, associationKey) :
+ session.retrieve(propType, associationKey);
+ ea.setProperty(prop.getName(), value);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.