【发布时间】:2020-02-21 15:17:44
【问题描述】:
在以下查询中添加“NULLS LAST”时,出现以下异常:
原因:com.microsoft.sqlserver.jdbc.SQLServerException:没有为参数号11设置值。
如果我删除 NULLS LAST 一切正常
如果我删除 CASE WHEN 代码并仅按一个特定列排序,它适用于 NULLS LAST,但我需要 CASE WHEN 上的所有列。
@Query("SELECT c FROM ClassSpecificationTableEntity c"
+ " LEFT JOIN c.owner o "
+ " LEFT JOIN c.domain d "
+ "WHERE ISNULL(c.classStructure.classification.description, '') LIKE :SEARCH "
+ " OR ISNULL(c.classStructure.description, '') LIKE :SEARCH "
+ " OR ISNULL(d.description, '') LIKE :SEARCH "
+ " OR ISNULL(o.description, '') LIKE :SEARCH "
+ " OR ISNULL(c.measurementUnit, '') LIKE :SEARCH "
+ " OR ISNULL(c.defaultValue, '') LIKE :SEARCH "
+ " OR ISNULL(c.dataType, '') LIKE :SEARCH "
+ " OR ISNULL(c.tooltip, '') LIKE :SEARCH "
+ " ORDER BY "
+ " CASE :ORDERBY" +
" WHEN 0 THEN c.classStructure.classification.description " +
" WHEN 1 THEN c.assetAttribId " +
" WHEN 2 THEN c.dataType " +
" WHEN 3 THEN c.measurementUnit " +
" WHEN 4 THEN c.domain.description " +
" WHEN 5 THEN c.owner.description " +
" WHEN 6 THEN c.defaultValue " +
" WHEN 7 THEN c.tooltip " +
" END DESC NULLS LAST"
)
Page<ClassSpecificationTableEntity> findByLikeSearchDESC(@Param(value="SEARCH") final String searchCrit, final Pageable pageable, @Param(value="ORDERBY") final String orderBy);
【问题讨论】:
-
你的
ON子句在哪里?
标签: java sql-server spring-boot jpql