Hi,
When I use DataStax Java Driver 4.7.2 with the Mapper, I got a class cast error:
java.lang.ClassCastException: com.datastax.oss.driver.internal.core.type.PrimitiveType cannot be cast to com.datastax.oss.driver.api.core.type.UserDefinedType
This error on the generated mapper MyCounterDaoImpl__MapperGenerated.java code:
UserDefinedType udtType = (UserDefinedType) boundStatementBuilder.getType("counter");
Here is the DAO:
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@CqlName("my_counter")
public class MyCounter {
@PartitionKey
private long id;
private long counter;
}
and the Mapper:
@Dao
@DefaultNullSavingStrategy(SET_TO_NULL)
public interface MyCounterDao {
@Query("UPDATE ${qualifiedTableId} SET counter = counter + :counter WHERE id= :id")
void create(MyCounter counter);
}
Why the generated code treat the counter (long) as UserDefinedType ?
if (value != null) {
UserDefinedType udtType = (UserDefinedType) boundStatementBuilder.getType("counter");
UdtValue udtValue = udtType.newValue();
myCounterHelper.set(value, udtValue, NullSavingStrategy.DO_NOT_SET);
boundStatementBuilder = boundStatementBuilder.setUdtValue("counter", udtValue);
} else if (nullSavingStrategy == NullSavingStrategy.SET_TO_NULL) {
boundStatementBuilder = boundStatementBuilder.setUdtValue("counter", null);
}
Thanks,
Dongsheng