The poster should write hibernate hql statement question:
SELECT r.Id FROM A r WHERE r.Status = :edcbatchStatus
This hql should be taken out after executionid的类型集合。根据报错信息,结果类型为List<String>,在这里,强转类型为List<A>An exception will be thrown. There are following solutions:
If you just want to get a collection of ids, then modify the type of forced conversion
The poster should write
hibernate
hql statement question:This hql should be taken out after execution
id
的类型集合。根据报错信息,结果类型为List<String>
,在这里,强转类型为List<A>
An exception will be thrown. There are following solutions:If you just want to get a collection of ids, then modify the type of forced conversion
If you want to get the entire object, you need to modify the hql statement
Although I am not familiar with Spring and haven’t written Java for a long time, I can see some problems from this code
From the error message, there is a problem when converting String to type A. There is only one sentence in the code for conversion:
That might be
getResultList()
本身取得的是一个List<String>
。从 SQL 来看,select r.Id
, then this guess is reasonable.So either change the return value to
List<String>
,要么在 SQL 里取得整个对象(还会有一些映射啊什么的,只能假设你已经配置好了),比如select r.* from ...
.