Key<ApiKey> existingApiKeyKey = objectifyFactory.begin().query(ApiKey.class)
.filter("apiKeyHash", apiKey.getApiKeyHash()).getKey();
if (apiKey.getId() == null &&
existingApiKeyKey != null) {
logger.error("Trying to add api key that is already added, apiKeyUserID: {}", apiKey.getApiKeyUserID());
throw new DuplicateApiKeyException();
}
}