How to get List<String> from List<Object[]> by converting the first element of array to String?
I tried writing like below but casting is not happening,
List<String> results = query.getResultList()
.stream()
.map(result ->{
Object[] temp = (Object[]) result;
return temp[0].toString();
})
.collect(Collectors.toList());
Below image shows type of results list
I am getting Error:java: incompatible types: java.lang.Object cannot be converted to java.util.List.
How to do this correctly using Java 8?
getResultList()? Second, what framework are you using to do these queries (JPA, Hibernate), and can you use a type-safe approach?