When using index parameters on Cassandra native queries, you cannot apply conditions to the same column more than once.
Query query = entityManager.createNativeQuery( "SELECT * FROM sample WHERE column_a = ? AND column_b >= ? AND column_b <= ?", Entity.class);
query.setParameter(0, "hello");
query.setParameter(1, 1);
query.setParameter(2, 10);
From CassandraParameterMetadataBuilder
for ( ColumnDefinitions.Definition definition : columnDefinitions ) {
String name = definition.getName();
Column column = table.getColumn( Identifier.toIdentifier( name ) );
Type hibernateType = column.getValue().getType();
int index = columnDefinitions.getIndexOf( name );
ordinalDescriptors[index] = new OrdinalParameterDescriptor( index + 1, hibernateType, 0 );
}
The above code uses indexOf to find the associated param index, but since the column name repeats it will always use the first index leaving elements in the ordinalDescriptors array as null. |