Reputation: 79
I am converting date string in format yyyy-MM-dd to com.datastax.driver.core.LocalDate using object mapper and save that data into Cassandra in my java spring boot project.
The type of my column in Cassandra is date and i am using com.datastax.driver.core.LocalDate in my java class.
But while converting map to my java class it throws error "com.fasterxml.jackson.databind.JsonMappingException: Problem deserializing property 'employeedateofbirth' (expected type: [simple type, class com.datastax.driver.core.LocalDate]; actual type: java.time.LocalDate
), problem: argument type mismatch".
I am not using java.time.LocalDate still it gives me argument mismatch error.
I even tried registering module by using the following code
ObjectMapper oMapper = new ObjectMapper().registerModule(new ParameterNamesModule()).registerModule(new Jdk8Module()).registerModule(new JavaTimeModule());
oMapper.findAndRegisterModules();
I have also tried some configuration for object mapper like
oMapper.configure(MapperFeature.USE_GETTERS_AS_SETTERS, false) ;
Even used annotation on my attribute:
@JsonDeserialize(using = LocalDateDeserializer.class)
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate employeedateofbirth;
But nothing seems to work for me. Any help would be appreciated. Thanks in advance.
Upvotes: 0
Views: 2563
Reputation: 26056
As the error message indicates, there is a type mismatch. Change this in your target class:
import com.datastax.driver.core.LocalDate;
into:
import java.time.LocalDate;
Upvotes: 2