backed out SGF-172 - moved to feature branch 1.3.x

This commit is contained in:
David Turanski
2013-04-17 10:21:36 -04:00
parent 3a4f727334
commit 477dca3f4f
9 changed files with 8 additions and 93 deletions

View File

@@ -47,7 +47,7 @@ class GemfireQueryCreator extends AbstractQueryCreator<QueryString, Predicates>
super(tree);
this.query = new QueryBuilder(entity,tree);
this.query = new QueryBuilder(entity);
this.indexes = new IndexProvider();
}

View File

@@ -48,6 +48,4 @@ abstract class GemfireRepositoryQuery implements RepositoryQuery {
public QueryMethod getQueryMethod() {
return this.queryMethod;
}
protected abstract boolean isCountQuery();
}

View File

@@ -65,7 +65,7 @@ public class PartTreeGemfireRepositoryQuery extends GemfireRepositoryQuery {
QueryString query = new GemfireQueryCreator(tree, method.getPersistentEntity()).createQuery(parameterAccessor
.getSort());
RepositoryQuery repositoryQuery = new StringBasedGemfireRepositoryQuery(query.toString(), method, template,isCountQuery());
RepositoryQuery repositoryQuery = new StringBasedGemfireRepositoryQuery(query.toString(), method, template);
return repositoryQuery.execute(prepareStringParameters(parameters));
}
@@ -102,12 +102,4 @@ public class PartTreeGemfireRepositoryQuery extends GemfireRepositoryQuery {
return result;
}
/* (non-Javadoc)
* @see org.springframework.data.gemfire.repository.query.GemfireRepositoryQuery#isCountQuery()
*/
@Override
protected boolean isCountQuery() {
return this.tree.isCountProjection();
}
}

View File

@@ -35,8 +35,8 @@ class QueryBuilder {
this.query = source;
}
public QueryBuilder(GemfirePersistentEntity<?> entity, PartTree tree) {
this(String.format(tree.isCountProjection()? "SELECT count(*) FROM /%s %s":"SELECT * FROM /%s %s", entity.getRegionName(), DEFAULT_ALIAS));
public QueryBuilder(GemfirePersistentEntity<?> entity) {
this(String.format("SELECT * FROM /%s %s", entity.getRegionName(), DEFAULT_ALIAS));
}
public QueryString create(Predicate predicate) {

View File

@@ -38,7 +38,6 @@ public class StringBasedGemfireRepositoryQuery extends GemfireRepositoryQuery {
private static final String INVALID_EXECUTION = "Paging and modifying queries are not supported!";
private final boolean isCountProjection;
private final QueryString query;
private final GemfireQueryMethod method;
private final GemfireTemplate template;
@@ -51,7 +50,7 @@ public class StringBasedGemfireRepositoryQuery extends GemfireRepositoryQuery {
* @param template must not be {@literal null}.
*/
public StringBasedGemfireRepositoryQuery(GemfireQueryMethod method, GemfireTemplate template) {
this(method.getAnnotatedQuery(), method, template, null);
this(method.getAnnotatedQuery(), method, template);
}
/**
@@ -63,8 +62,7 @@ public class StringBasedGemfireRepositoryQuery extends GemfireRepositoryQuery {
* @param method must not be {@literal null}.
* @param template must not be {@literal null}.
*/
public StringBasedGemfireRepositoryQuery(String query, GemfireQueryMethod method, GemfireTemplate template,
Boolean isCountProjection) {
public StringBasedGemfireRepositoryQuery(String query, GemfireQueryMethod method, GemfireTemplate template) {
super(method);
@@ -73,11 +71,6 @@ public class StringBasedGemfireRepositoryQuery extends GemfireRepositoryQuery {
this.query = new QueryString(StringUtils.hasText(query) ? query : method.getAnnotatedQuery());
this.method = method;
this.template = template;
if (isCountProjection == null && StringUtils.hasText(method.getAnnotatedQuery())) {
this.isCountProjection = method.getAnnotatedQuery().toLowerCase().contains("count(*)");
} else {
this.isCountProjection = isCountProjection;
}
if (method.isPageQuery() || method.isModifyingQuery()) {
throw new IllegalStateException(INVALID_EXECUTION);
@@ -111,14 +104,6 @@ public class StringBasedGemfireRepositoryQuery extends GemfireRepositoryQuery {
} else {
throw new IncorrectResultSizeDataAccessException(1, result.size());
}
} else if (isCountProjection) {
int count = (Integer) result.iterator().next();
if (long.class.isAssignableFrom(method.getReturnedObjectType())) {
return (long) count;
} else {
return count;
}
} else {
throw new IllegalStateException("Unsupported query: " + query.toString());
}
@@ -144,12 +129,4 @@ public class StringBasedGemfireRepositoryQuery extends GemfireRepositoryQuery {
return source.getClass().isArray() ? CollectionUtils.arrayToList(source) : Collections.singleton(source);
}
/* (non-Javadoc)
* @see org.springframework.data.gemfire.repository.query.GemfireRepositoryQuery#isCountQuery()
*/
@Override
protected boolean isCountQuery() {
return this.isCountProjection;
}
}

View File

@@ -165,7 +165,7 @@ public class GemfireRepositoryFactory extends RepositoryFactorySupport {
String namedQueryName = queryMethod.getNamedQueryName();
if (namedQueries.hasQuery(namedQueryName)) {
return new StringBasedGemfireRepositoryQuery(namedQueries.getQuery(namedQueryName), queryMethod,
template,false);
template);
}
return new PartTreeGemfireRepositoryQuery(queryMethod, template);