To cast a String to a long in JPQL, you can use the CAST function as follows:

SQL
SELECT e FROM Employee e WHERE e.employeeId = CAST(:id AS long)

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.