insert.value(cm.getColumnName(), bindMarker());
return insert.toString();
}
case GET:
{
Select select = table == null
? select().all().from(mapper.getKeyspace(), mapper.getTable())
: select().all().from(table);
Select.Where where = select.where();
for (int i = 0; i < mapper.primaryKeySize(); i++)
where.and(eq(mapper.getPrimaryKeyColumn(i).getColumnName(), bindMarker()));
return select.toString();
}
case DEL:
{
Delete delete = table == null
? delete().all().from(mapper.getKeyspace(), mapper.getTable())
: delete().all().from(table);
Delete.Where where = delete.where();
for (int i = 0; i < mapper.primaryKeySize(); i++)
where.and(eq(mapper.getPrimaryKeyColumn(i).getColumnName(), bindMarker()));
return delete.toString();
}
case SLICE:
case REVERSED_SLICE:
{
Select select = table == null
? select().all().from(mapper.getKeyspace(), mapper.getTable())
: select().all().from(table);
Select.Where where = select.where();
for (int i = 0; i < mapper.partitionKeys.size(); i++)
where.and(eq(mapper.partitionKeys.get(i).getColumnName(), bindMarker()));
if (startBoundSize > 0) {
if (startBoundSize == 1) {
String name = mapper.clusteringColumns.get(0).getColumnName();
where.and(startInclusive ? gte(name, bindMarker()) : gt(name, bindMarker()));
} else {
List<String> names = new ArrayList<String>(startBoundSize);
List<Object> values = new ArrayList<Object>(startBoundSize);
for (int i = 0; i < startBoundSize; i++) {
names.add(mapper.clusteringColumns.get(i).getColumnName());
values.add(bindMarker());
}
where.and(startInclusive ? gte(names, values) : gt(names, values));
}
}
if (endBoundSize > 0) {
if (endBoundSize == 1) {
String name = mapper.clusteringColumns.get(0).getColumnName();
where.and(endInclusive ? gte(name, bindMarker()) : gt(name, bindMarker()));
} else {
List<String> names = new ArrayList<String>(endBoundSize);
List<Object> values = new ArrayList<Object>(endBoundSize);
for (int i = 0; i < endBoundSize; i++) {
names.add(mapper.clusteringColumns.get(i).getColumnName());
values.add(bindMarker());
}
where.and(endInclusive ? lte(names, values) : lt(names, values));
}
}
select = select.limit(bindMarker());
if (kind == Kind.REVERSED_SLICE)
select = select.orderBy(desc(mapper.clusteringColumns.get(0).getColumnName()));
return select.toString();
}
}
throw new AssertionError();
}