If result of query is just one column JPA returns a List<String> instead of List<Object[]>
Closed this issue · 10 comments
java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
at org.qlrm.mapper.JpaResultMapper.list(JpaResultMapper.java:34)
at org.qlrm.executor.JpaQueryExecutor.executeSelect(JpaQueryExecutor.java:21)
i have same issue.
just one column makes error
is this not fixed?
java.lang.String cannot be cast to [Ljava.lang.Object;
at org.qlrm.mapper.JpaResultMapper.list(JpaResultMapper.java:40) ~[qlrm-3.0.1.jar:na]
@babo3yong2 Which version are you using?
And how does the query look like you try to execute?
@simasch
i used 3.0.1 version
for example, query is like "select position_id from position"
And how does the object look like you want to create?
execute query
JpaResultMapper jpaResultMapper = new JpaResultMapper();
return jpaResultMapper.list(executeQuery, MidTermStationDTO.class);
Object
@Getter
@Setter
@AllArgsConstructor
@ToString
public class MidTermStationDTO {
private String position_id;
}
I cannot reproduce your problem.
Can you please create a minimal reproducible example on GitHub? Thank you
i made simple project. check please
https://github.com/babo3yong2/qlrm_example
http://localhost:8099/hello_one -> error
http://localhost:8099/hello_two -> ok
thank you for your help.
Thanks. I can reproduce the issue now.
The Hibernate behavior is not the same if selecting only one row or multiple rows.
@babo3yong2
Version 3.0.4 has been released with the fix
@simasch
thank you so much
it works