code: private <T> T newInstance(DatastoreId id, DatastoreType datastoreType, DynamicType<?> types, TransactionalCache.Mode cacheMode) {
          validateType(types);
          InstanceInvocationHandler invocationHandler = new InstanceInvocationHandler(datastoreType, getProxyMethodService());
          T instance = proxyFactory.createInstance(invocationHandler, types.getCompositeType());
          cache.put(id, instance, cacheMode);
          return instance;
      }
docs: Create a proxy instance which corresponds to the given datastore type.
  
  @param datastoreType
  The datastore type.
  @param <T>
  The instance type.
  @return The instance.