How to cast String to long in Jpql i have used CAST(mem.employeeId AS
Loading
How to cast String to long in Jpql i have used CAST(mem.employeeId AS
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mohamed Azarudeen ZPosted May 14, 2023, 6:03 PM
To cast a String to a long in JPQL, you can use the CAST function as follows:
In this example, the :id parameter is a String that you want to cast to a long. The CAST function converts the parameter to a long before comparing it to the employeeId attribute.
Make sure that the value of the :id parameter is a valid long value, otherwise the query will fail with a ClassCastException.