We use UUIDs as a binary to guard against SQL injection or guessing IDs. As part of upgrading Spring Boot and Hibernate versions, I'm trying to move a custom dialect SQL function directly into a @Query, and getting this error:
Parameter 1 of function 'left()' has type 'STRING', but argument is of type 'java.lang.Object'
My query is as follows:
@Query("SELECT p FROM #{#entityName} p WHERE LEFT(HEX(p.uuid), 32) = LEFT(HEX(:searchUuid), 32)")
Optional<T> findByUuid(@Param("searchUuid") UUID searchUuid);
Can I accomplish this in the Query, or can this only be done with a custom function on the DB / within a dialect?