JdbcTemplate queryForList return value in case of no results
Asked Answered
S

2

26

The question is pretty much summed up in the title. What will JdbcTemplate.queryForList() return when the query returns no results. Will it return an empty List or null value? I couldn't find a definitive answer from the documentation. Thanks in advance!

Selfhypnosis answered 17/7, 2014 at 7:51 Comment(0)
A
32

The javadoc states that it will return

a List of objects that match the specified element type

If there's no element, the list is empty.

Arthritis answered 17/7, 2014 at 9:47 Comment(1)
I was not sure if I could make that assumption. Seems I could. Thanks alot!Selfhypnosis
E
4

It will return an empty list. So you can test it with list.isEmpty(). It will return true in this case.

Entangle answered 10/4, 2018 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.