I have a query like below that doesn't work.
It throws IndexOutOfBoundsException: Index: 0, Size: 0
(sorry I can't post the whole stacktrace as it is in my workstation (remote)) This started to be an issue when I upgraded from Spring Boot 1.5.2.RELEASE
to 1.5.22.RELEASE
@Transactional(readOnly = true)
@Query(value = "SELECT q.id as someId, q.name as someName from Quote q where q.id in (:quoteIds)")
List<Tuple> selectSomeThings(@Param("quoteIds") List<Long> quoteIds)
Now when I try to just select 1 column like so,
@Transactional(readOnly = true)
@Query(value = "SELECT q.id as someId from Quote q where q.id in (:quoteIds)")
List<Tuple> selectSomeThings(@Param("quoteIds") List<Long> quoteIds)
or
@Transactional(readOnly = true)
@Query(value = "SELECT q.name as someName from Quote q where q.id in (:quoteIds)")
List<Tuple> selectSomeThings(@Param("quoteIds") List<Long> quoteIds)
it works. Just doesn't work when I select 2 at the same time.
I would recommend to return a Bean instance from the repository methode.
Example here:
@Query("SELECT " +
" new com.path.to.Tuple(v.id, v.name) " +
"FROM " +
" Quote v where v.id in (:quoteIds) ")
List<Tuple> find(@Param("quoteIds") List<Long> quoteIds);
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.