private List<T> executeQuery() { executedQueryType = QueryType.LIST; RepositoryHooks.beforeQuery(this); List<T> list = hasForcedResponse(executedQueryType) ? getForcedResultList() : doExecuteQuery(); executedResponse = list; RepositoryHooks.afterQuery(this); return list; }
@SuppressWarnings("unchecked") private T executeQueryById() { SimpleCondition c = (SimpleCondition) condition; IdRef<T> id = (IdRef<T>) c.getWhereValue(); executedQueryType = QueryType.FETCH; RepositoryHooks.beforeQuery(this); T retrieved = hasForcedResponse(executedQueryType) ? getForcedResultFetch() : doExecuteQueryById(id); executedResponse = retrieved; RepositoryHooks.afterQuery(this); return retrieved; }
@Override public void beforeQuery(QueryBuilder<CachedEntity> q) { if (q.hasCursor() || q.hasForcedResponse()) { return; } String key = GSON.to(q.toMap()); Map<String, Object> cache = caches.get(q.getExecutedQueryType()); if (cache.containsKey(key)) { q.forceResult(q.getExecutedQueryType(), cache.get(key)); } }
public List<IdRef<T>> ids() { if (hasPostFilter() || hasPostOrder()) { throw new RuntimeException("ids() cannot be used with post query filter or order. You may need to add @Index to your model attributes."); } r.namespace().set(getClazz()); try { executedQueryType = QueryType.IDS; RepositoryHooks.beforeQuery(this); List<IdRef<T>> ids = hasForcedResponse(executedQueryType) ? getForcedResultIds() : doFetchIds(); executedResponse = ids; RepositoryHooks.afterQuery(this); return ids; } finally { r.namespace().reset(); } }