Hibernate Console: how to use List Parameters
已回答
Hi,
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
andbetween
can be used as follows: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:
That raises a Dialog where you need to set the catName value.
So, doesn't it work with
syntax?
Yes, that syntax works, is not what I expected, but I'll use it.
Thanks.
Just had the case, the "(1L, 2L)" syntax worked for me right now (IDEA version 2021.1.3).