I need help with Spring Boot and MyBatis integration. I have an issue with custom BaseTypeHandler. I've created a mapper:
@MappedTypes({LocalDateTime.class})
public class LocalDateTimeHandler extends BaseTypeHandler<LocalDateTime> {
I've added a type handler:
sqlSessionFactory.setTypeHandlers(new LocalDateTimeHandler[]{new LocalDateTimeHandler()});
And I have next error:
org.apache.ibatis.executor.ExecutorException: No constructor found in com.some.space.SomeObject matching [java.lang.Integer, java.sql.Timestamp, java.sql.Timestamp]
Where SomeObject looks like:
public class SomeObject {
private Long id;
private LocalDateTime created;
private LocalDateTime updated;
public SomeObject(Integer id, LocalDateTime created, LocalDateTime updated){
//..........
}
}
I using mybatis-spring and spring-boot-starter-web version 1.3.2.
All examples about working with TypeHandlers are on the XML configuration, but I need to use Java configs way. What I'm doing wrong?
UPD:
My mapper:
@Component
@Mapper
public interface SomeObjectRepository {
@Select("SELECT * FROM some_objects")
@Results(value = {
@Result(property = "created", column = "created_date", typeHandler = LocalDateTimeTypeHandler.class, jdbcType = JdbcType.TIMESTAMP),
@Result(property = "updated", column = "updated_date", typeHandler = LocalDateTimeTypeHandler.class, jdbcType = JdbcType.TIMESTAMP)
})
List<SomeObject> getAll();
}