Bind multiple values ​​in sleep mode using the game environment

I am trying to create a request in the Play platform, I have

select * from Candidate c where (:schools member of c.schools) 

After binding: a school with a list with one element returns a result, but if I associate a List with several elements, nothing happens.

Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: {vector} [select c from models.Candidate c where (:schools0_, :schools1_ member of c.schools)  group by c.id order by RAND()]

I actually need something like

select * from candidate where schools in (x,x,x,x,x);

The relationship between the candidate and the school is in a related table.

Can multiple values ​​be related?

+3
source share
2 answers

With Hibernate, you can also use the list directly.

select c from Candidate c join c.schools as school where school.id in (:schools)

Parameter type: school is entered according to your identifiers, for example, List<Int>or List<Long>.

+1
source

, - , . , sql :

 select c from Candidate c inner join c.schools as school where school.id in (25980,25981)"

- c.schools.id, c.schools .

, http://www.javatx.cn/hibernate/reference/en/html/queryhql.html

+4

Source: https://habr.com/ru/post/1766944/


All Articles