From my experience I will tell you. There are two scenarios
1) you want to specify a parameter in the query whose value is set dynamically.
eg: where user_id = :userId
You will not get any problems here if you specify a parameter with the same name as "userId";
2) you attribute the value
eg: select count(id) :: integer
when you do this, you need to use an escape character, otherwise hibernate will assume that it is a parameter. and this will lead to the error "All parameters are not set", you can overcome this by writing code with the escape character
eg:select count(id) \\:\\: integer
So this will solve your problem. And if you mistakenly use a slash instead of a backslash, you will get the error message “after the prefix”
Worng: select count(id)//://: integer right:select count(id)\\:\\: integer
But I strongly recommended using the CAST function instead of using the "::" this operator ie select CAST(count(id) as integer) This is the best way to cast types, and this will lead to minimal errors, and think that this is a parameter. and this will lead to the error "All parameters are not set", you can overcome this by writing code with the escape character
eg:select count(id) \\:\\: integer
So this will solve your problem. And if you mistakenly use a slash instead of a backslash, you will get the error message “after the prefix”
Worng: select count(id)//://: integer right:select count(id)\\:\\: integer
But I strongly recommended using the CAST function instead of using the "::" this operator ie select CAST(count(id) as integer) This is the best way to type cast, resulting in minimal errors