简体   繁体   中英

Calling named query with `in()`, in Hibernate

This is my Hibernate namedQuery:

@NamedQuery(name = "getLanguagesForIds", query = "select l from Language l where l.languageId in(:ids)")

When I tried to execute the query, Hibernate is throwing exception:

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer

I am passing the language ids as comma separated, like 1,2. Does anyone know how to solve this issue?

使用List = new ArrayList来保存ID,并将其作为参数值而不是逗号分隔的字符串传递。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM