1

I encountered a very urgly problem when I's trying to count the number of records using Hibernate. By debuging I get the HQL and related error:

HQL:

SELECT COUNT(id) AS totalSize FROM UserAccount WHERE 1 = 1 AND role IN (:role_list) AND agent.id = :agentId

Set Parameter:

query.setParameter("role_list", parameter.getRoles());
query.setParameter("agentId", parameter.getAgentId());

Error:

java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Integer

I'm confused with that since It worked fine previously when I set its parameter with sequence instead of name. Can anybody give me ideas for that.

Thanks in advance.

1 Answer 1

2

Stupid question, I should set collection parameter with the method of 'setParameterList'.

Sign up to request clarification or add additional context in comments.

1 Comment

I guess you could simply remove your question! ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.