Jakarta Persistence (JPA) Method

Expression<X> cast(
  Class<X> type
)


Cast this expression to the specified type, returning a new expression object. Unlike Expression.as, this method does result in a runtime type conversion.

Providers are required to support casting scalar expressions to String, and String expressions to Integer, Long, Float, and Double. Support for typecasts between other basic types is not required.

Parameters:
type - a basic type
Returns:
a scalar expression of the given basic type.
Since:
Jakarta Persistence (JPA) 3.2