I am using spring boot 2.4.1 with spring-boot-starter-data-cassandra.
Here is the Repository class
@Repository
public interface UserRepository extends CassandraRepository<UserModel, String> {
}
Below is the POJO
@Table("user")
public class UserModel {
@PrimaryKeyColumn(name = "userid", type = PrimaryKeyType.PARTITIONED)
private String userId;
@Column("emailid")
private String emailId;
@Column("phonenumber")
private String phoneNumber;
//getters and setters
}
Here is the class calling update method :
@Component
public class UpdateTask {
@Autowired
private UserRepository userRepository;
public void removePhoneNumber(UserModel t) {
t.setPhoneNumber(null);
userRepository.save(t);
}
}
Problem is I want to update the phone number field to null as user wants to remove their phone number. But cassandra ignores the null value set. How to explicitly set a value to null in cassandra ?