private void searchCustomers() { String jSonDave = (String) customerTemplate.findUnique("select * from /Customer where emailAddress.value=$1","dave@matthews.com"); log.info(jSonDave); SelectResults<String> results = customerTemplate.find("select * from /Customer where emailAddress.value=$1", "alicia@keys.com"); String jSonAlicia = results.iterator().next(); log.info(jSonAlicia); }
/** * Finds all available {@link Session Sessions} with the particular attribute indexed by {@link String name} * having the given {@link Object value}. * * @param indexName {@link String name} of the indexed {@link Session} attribute. * (e.g. {@link org.springframework.session.FindByIndexNameSessionRepository#PRINCIPAL_NAME_INDEX_NAME}). * @param indexValue {@link Object value} of the indexed {@link Session} attribute to search on * (e.g. {@literal username}). * @return a mapping of {@link Session#getId()} Session IDs} to {@link Session} objects. * @see org.springframework.session.Session * @see java.util.Map * @see #prepareQuery(String) * @see #commit(Session) * @see #configure(Session) * @see #registerInterest(Session) * @see #touch(Session) */ @Override public Map<String, Session> findByIndexNameAndIndexValue(String indexName, String indexValue) { SelectResults<Session> results = getSessionsTemplate().find(prepareQuery(indexName), indexValue); Map<String, Session> sessions = new HashMap<>(results.size()); results.asList().forEach(session -> sessions.put(session.getId(), touch(commit(registerInterest(configure(session)))))); return sessions; }
/** * Finds an existing, non-expired {@link Session} by ID. * * If the {@link Session} is expired, then the {@link Session} is deleted and {@literal null} is returned. * * @param sessionId {@link String} containing the {@link Session#getId() ID}} of the {@link Session} to get. * @return an existing {@link Session} by ID or {@literal null} if no {@link Session} exists * or the {@link Session} expired. * @see AbstractGemFireOperationsSessionRepository.GemFireSession#from(Session) * @see org.springframework.session.Session * @see #commit(Session) * @see #configure(Session) * @see #delete(Session) * @see #registerInterest(Session) * @see #touch(Session) */ @Nullable public Session findById(String sessionId) { Session storedSession = getSessionsTemplate().get(sessionId); if (storedSession != null) { storedSession = storedSession.isExpired() ? delete(storedSession) : touch(commit(registerInterest(configure(GemFireSession.from(storedSession))))); } return storedSession; }
void doSave(@NonNull Session session) { // Save Session As GemFireSession getSessionsTemplate().put(session.getId(), GemFireSession.from(session)); // Commit Session commit(session); }
/** * Deletes (removes) any existing {@link Session} from GemFire. This operation * also results in a SessionDeletedEvent. * * @param sessionId a String indicating the ID of the Session to remove from GemFire. * @see org.springframework.data.gemfire.GemfireOperations#remove(Object) * @see #handleDeleted(String, Session) */ public void deleteById(String sessionId) { handleDeleted(sessionId, getSessionsTemplate().<Object, Session>remove(sessionId)); } }