Skip to content

Commit a5b03c1

Browse files
committed
cassandra fixes
1 parent 7977fd2 commit a5b03c1

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

cassandra-driver/src/main/java/org/eclipse/jnosql/diana/cassandra/column/CassandraConverter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ private static UDT getUDT(String name, UDTValue udtValue) {
132132
}
133133

134134
private static boolean isUDTIterable(Object result) {
135-
return StreamSupport.stream(Iterable.class.cast(result).spliterator(), false)
135+
final Iterable<?> iterable = Iterable.class.cast(result);
136+
if (!iterable.iterator().hasNext()) {
137+
return false;
138+
}
139+
return StreamSupport.stream(iterable.spliterator(), false)
136140
.allMatch(UDTValue.class::isInstance);
137141
}
138142

cassandra-driver/src/main/java/org/eclipse/jnosql/diana/cassandra/column/QueryUtils.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,22 @@ private static void insertSingleField(Column column, Insert insert) {
128128

129129
public static BuiltStatement select(ColumnQuery query, String keySpace) {
130130
String columnFamily = query.getColumnFamily();
131-
131+
final List<String> columns = query.getColumns();
132132
if (Objects.isNull(query.getCondition())) {
133-
return QueryBuilder.select().all().from(keySpace, columnFamily);
133+
if (columns.isEmpty()) {
134+
return QueryBuilder.select().all().from(keySpace, columnFamily);
135+
} else {
136+
return QueryBuilder.select(columns.toArray()).from(keySpace, columnFamily);
137+
}
138+
134139
}
135-
Select.Where where = QueryBuilder.select().all().from(keySpace, columnFamily).where();
140+
Select.Where where;
141+
if (columns.isEmpty()) {
142+
where = QueryBuilder.select().all().from(keySpace, columnFamily).where();
143+
} else {
144+
where = QueryBuilder.select(columns.toArray()).from(keySpace, columnFamily).where();
145+
}
146+
136147
if (query.getLimit() > 0) {
137148
if (CassandraQuery.class.isInstance(query)) {
138149
where.setFetchSize((int) query.getLimit());

0 commit comments

Comments
 (0)