使用 cast in order by 子句 JPQL
Use cast in order by clause JPQL
我有一个 JPQL 查询,我想在其中的 order by 子句中使用强制转换运算符。查询在 SQL 中有效,但应用程序在运行时给出了显示的错误。如何在 JPQL 查询中使用 orderby 子句中的强制转换?提前致谢。
@Query("SELECT a FROM tableA a where a.tableB.ID = :ID ORDER BY cast(col as unsigned)")
错误
Caused by: org.hibernate.QueryException: Could not resolve requested type for CAST : unsigned : unsigned [SELECT r FROM classname a where a.tableB.ID = :ID ORDER BY CAST(col as unsigned)]
我认为不支持未签名。 interger
可能是最接近的。
@Query("SELECT a FROM tableA a where a.tableB.ID = :ID ORDER BY cast(col as integer)")
我有一个 JPQL 查询,我想在其中的 order by 子句中使用强制转换运算符。查询在 SQL 中有效,但应用程序在运行时给出了显示的错误。如何在 JPQL 查询中使用 orderby 子句中的强制转换?提前致谢。
@Query("SELECT a FROM tableA a where a.tableB.ID = :ID ORDER BY cast(col as unsigned)")
错误
Caused by: org.hibernate.QueryException: Could not resolve requested type for CAST : unsigned : unsigned [SELECT r FROM classname a where a.tableB.ID = :ID ORDER BY CAST(col as unsigned)]
我认为不支持未签名。 interger
可能是最接近的。
@Query("SELECT a FROM tableA a where a.tableB.ID = :ID ORDER BY cast(col as integer)")