When using index parameters on Cassandra native queries, you cannot apply conditions to the same column more than once.
{code:java} 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); {code}
From CassandraParameterMetadataBuilder {code:java} for ( ColumnDefinitions.Definition definition : columnDefinitions ) { String name = definition.getName(); Column column = table.getColumn( Identifier.toIdentifier( name ) ); Type hibernateType = column.getValue().getType(); // cassandra side index is 0-based, hibernate side index is 1-based int index = columnDefinitions.getIndexOf( name ); ordinalDescriptors[index] = new OrdinalParameterDescriptor( index + 1, hibernateType, 0 ); } {code}
The above code uses indexOf to find the associated param index, but since the column name repeats it will always use the first index instance leaving elements in the ordinalDescriptors array as null.
|
|