I am using sql queries to implement pagination in ignite cache. Below is my
code to build sql to be passed to SQLQuery. It looks very messy as there are
lot of checks and if else. Is there something in ignite like builder which
will do the task?
String sql = " select * from Employee"
private String buildSql(String sql, String sortByField, String sortOrder,
Integer startIndex, Integer endIndex) {
boolean isOrdered = false;
if (DataConstants.START_DATE.equals(sortByField)) {
sql = sql + "order by " + DataConstants.START_DATE;
isOrdered = true;
} else if (DataConstants.ISACTIVE.equals(sortByField)) {
sql=sql +"order by "+DataConstants.ISACTIVE;
isOrdered = true;
}.......
........
.........
if (isOrdered &&
DataConstants.DESCENDING_ORDER.equals(sortOrder)) {
sql = sql + " " + DataConstants.DESCENDING_ORDER;
}
if (startIndex != null) {
sql = sql + " limit " + startIndex;
if (endIndex != null) {
sql = sql + " , " + endIndex;
}
}
return sql;
}
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Is-there-any-such-thing-as-SQlBuilder-in-apache-Ignite-for-SQLQuery-tp6541.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.