String Cast for int Hibernate

1

Does anyone know how to do a cast from String to int within Query in this search, the variable "searchString"?

@Query("SELECT s FROM StoreOrder s INNER JOIN s.user u WHERE lower(u.fullname) LIKE %:searchString% OR u.totalamount=:searchString")
public Page<StoreOrder> findBySearch(@Param("searchString") String searchString, Pageable pageable);
    
asked by anonymous 20.03.2015 / 18:07

1 answer

1

Hibernate (HQL) SQL supports CAST in a similar way to native SQL, except that the types are Java and not the database types. Therefore:

u.totalamount = CAST(:searchString as Integer)
    
20.03.2015 / 19:10