SGF-131. Fixed count() problem

This commit is contained in:
David Turanski
2012-09-28 09:37:02 -04:00
parent 4c95b7044c
commit 4d01d1206d

View File

@@ -12,14 +12,14 @@ import org.springframework.data.gemfire.repository.Wrapper;
import org.springframework.data.repository.core.EntityInformation; import org.springframework.data.repository.core.EntityInformation;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import com.gemstone.gemfire.GemFireCheckedException;
import com.gemstone.gemfire.GemFireException;
import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.query.SelectResults;
/** /**
* Basic repository implementation. * Basic repository implementation.
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author David Turanski
*/ */
public class SimpleGemfireRepository<T, ID extends Serializable> implements GemfireRepository<T, ID> { public class SimpleGemfireRepository<T, ID extends Serializable> implements GemfireRepository<T, ID> {
@@ -135,14 +135,8 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
*/ */
@Override @Override
public long count() { public long count() {
return template.execute(new GemfireCallback<Long>() { SelectResults<Integer> results = template.find("select count(*) from " + template.getRegion().getFullPath());
@Override return (long)results.iterator().next();
@SuppressWarnings("rawtypes")
// TODO: Take into account keySetOnServer()
public Long doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return Long.valueOf(region.keySet().size());
}
});
} }
/* /*