In the following code:
return new HashSet<>(namedParameterJdbcTemplate.query(
SOME_SQL_QUERY_STRING,
parametersMap,
(resultSet, rowNum) -> resultSet.getBigDecimal("GETID")
));
I'm getting a red line under (resultSet, rowNum) -> resultSet.getBigDecimal("GETID"))
and the following error : No instance(s) of type variable(s) T exist so that List<T> conforms to Integer
. Can someone please help me and tell why this is happening?
The fundamental problem is that a different (unwanted) overloaded version of the "query" method is inferred (based on the code) and the lambda (Function) given as third parameter is not appropriate for this version of "query".
A way to fix this is to "force" the query function you want by providing the type parameter as such:
return new HashSet<>(namedParameterJdbcTemplate.<BigDecimal>query( ...
add an explicit casting to your method call
in my case I have
<T> Map<String, T> getMap(@NotNull String rootPath, @NotNull Class<T> type)
and I used it like
LinkedHashMap<String,String> x = xmlRegestryFile.getMap("path/to/map/of/string", String.class)
but it failed and gave me that error, so I overcomed this error by adding casting
x = (LinkedHashMap<String, String>) xmlRegestryFile.getMap("my/path", String.class)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.