Hibernate Console: how to use List Parameters




Im trying to test a query in the Hibernate Console like this one:


SELECT u FROM User u WHERE u.id IN :ids


Where u.id is a Long field.

How do i need to set the parameter to make it work?

I tried:

  • 1L,2L
  • {1L, 2L}
  • (1L, 2L)
  • Arrays.asList(1L, 2L)

But i didn't manage to work.

Please help!!

Thanks in advance!!



Try to write parameter list in brackets. According to documentation following syntax is supported:

in and between can be used as follows:

from DomesticCat cat where cat.name between 'A' and 'B'
from DomesticCat cat where cat.name in ( 'Foo', 'Bar', 'Baz' )

Hi Andrey, 

Thanks for your response, but i meant how to deal with parameters list in the IntelliJ "Hibernate Console", not in JPQL. Maybe it'll be clear with the following image:

- screenshot (i don't know why i couldn't upload this image in the comment)

Thanks in advance.


Sorry it is not quite clear: on the screenshot I do not see the complete query you are using. Do you mean how to set parameter list via one parameter when using  dialog? Doesn't it work if use separate user parameter per each list parameter?


Yes, i meant how to set a parameter list value when using the dialog.

An example of the query could be:

from DomesticCat cat where cat.name in :catName

That raises a Dialog where you need to set the catName value.


So, doesn't it work with 

from DomesticCat cat where cat.name in (:catName, :docName, :anotherName)



Yes, that syntax works, is not what I expected, but I'll use it.



Just had the case, the "(1L, 2L)" syntax worked for me right now (IDEA version 2021.1.3).


Please sign in to leave a comment.