Description
I have multiple domain aggregates using default row mappers. However, I have one that needs a custom row mapper. When attempting to register and use a custom row mapper for this certain domain through a bean definition of QueryMappingConfiguration, the row mapper is not used and still defaults to the default entity row mapper.
I created a row mapper class:
public class TestObjectRowMapper implements RowMapper<TestObject> {
@Override
public TestObject mapRow(ResultSet rs, int rowNum) throws SQLException {
TestObject testObject = new TestObject();
...
return testObject;
}
}
as well as registering it in a bean of type QueryMappingConfiguration
@Bean
QueryMappingConfiguration rowMappers() {
return new DefaultQueryMappingConfiguration()
.registerRowMapper(TestObject.class, new TestObjectRowMapper());
}
According to the documentation, this should be a valid way of registering a row mapper. I want to avoid using the @Query
annotation, as I will then have to override all of the existing findAll, findById methods in order to use my row mapper for those methods. Either I am missing something, or there is a bug in bean registration for row mappers.
Ideally, custom row mappers should work with methods inherited from extending CrudRepository/PagingAndSortingRepository as well as custom methods. Thanks in advance.