// Convert entities to EntityProxies or EntityProxyIds
boolean isProxy = BaseProxy.class.isAssignableFrom(returnClass);
boolean isId = EntityProxyId.class.isAssignableFrom(returnClass);
if (isProxy || isId) {
Class<? extends BaseProxy> proxyClass = assignableTo.asSubclass(BaseProxy.class);
BaseProxy entity = resolveClientProxy(domainValue, proxyClass,
propertyRefs, key, prefix);
if (isId) {
return assignableTo.cast(((EntityProxy) entity).stableId());
}
return assignableTo.cast(entity);