DATAJPA-1171 - CrudRepository.exists(…) does no longer contain a 1 = 1 clause in query.

Changed the query generating code to use streams and joiner which made it simpler and the use of 1 = 1 superfluous.

Original pull request: #212.
This commit is contained in:
Jens Schauder
2017-09-04 12:10:54 +02:00
committed by Oliver Gierke
parent f10d15bf0a
commit c7da62ffbc

View File

@@ -70,6 +70,7 @@ import org.springframework.util.StringUtils;
* @author Christoph Strobl
* @author Mark Paluch
* @author Sébastien Péralta
* @author Jens Schauder
*/
public abstract class QueryUtils {
@@ -183,14 +184,14 @@ public abstract class QueryUtils {
Iterable<String> idAttributes) {
StringBuilder sb = new StringBuilder(String.format(COUNT_QUERY_STRING, countQueryPlaceHolder, entityName));
sb.append(" WHERE ");
String append = " WHERE ";
for (String idAttribute : idAttributes) {
sb.append(append);
sb.append(String.format(EQUALS_CONDITION_STRING, "x", idAttribute, idAttribute));
sb.append(" AND ");
append = " AND ";
}
sb.append("1 = 1");
return sb.toString();
}