You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect this code to return a List where some items in the list are the type Message when the value of the "uploadType" column is equal to "message" (Message extends MediaItem). This is not the case. All items in the list are MediaItems. Through debugging, I found the problem. The problem starts in JdbcTemplateMapperFactory.newResultSetExtractor(Type target):
public <T> ResultSetExtractorImpl<T> newResultSetExtractor(Type target) throws MapperBuildingException {
return new ResultSetExtractorImpl<T>(this.<T>newJdbcMapper(target));
}
The call to JdbcTemplateMapperFactory.newJdbcMapper() switches types to a JdbcMapperFactory:
public <T> JdbcMapper<T> newJdbcMapper(Type target) {
return JdbcMapperFactory.newInstance(this).newMapper(target);
}
Calling JdbcMapperFactory.newInstance(this) should copy all of the properties from the JdbcTemplateMapperFactory to the new JdbcMapperFactory, but it does not. The copy constructor for the parent class, AbstractMapperFactory, does not copy the list of discriminators:
I am using version 8.2.3, and I cannot add a discriminator column to JdbcTemplateMapperFactory.
Here is my code using JdbcTemplateMapperFactory:
I expect this code to return a List where some items in the list are the type Message when the value of the "uploadType" column is equal to "message" (Message extends MediaItem). This is not the case. All items in the list are MediaItems. Through debugging, I found the problem. The problem starts in JdbcTemplateMapperFactory.newResultSetExtractor(Type target):
The call to JdbcTemplateMapperFactory.newJdbcMapper() switches types to a JdbcMapperFactory:
Calling JdbcMapperFactory.newInstance(this) should copy all of the properties from the JdbcTemplateMapperFactory to the new JdbcMapperFactory, but it does not. The copy constructor for the parent class, AbstractMapperFactory, does not copy the list of discriminators:
Therefore, you can never use discriminators with the JdbcTemplateMapperFactory using a ResultSetExtractor. Adding the line:
to the copy constructor fixes the problem and my code works as expected.
The text was updated successfully, but these errors were encountered: