@Programmatic @Override @SuppressWarnings("unchecked") public <T> T firstMatch(final Query<T> query) { // NB: this impl does NOT delegate to RepositoryService, because this implementation incorrectly // always performs a flush // irrespective of the autoflush setting. (The RepositoryService corrects that error). flush(); // auto-flush any pending changes final ObjectAdapter firstMatching = persistenceSessionServiceInternal.firstMatchingQuery(query); return (T) ObjectAdapter.Util.unwrap(firstMatching); }