错误提示
Name for parameter binding must not be null or empty! On JDKs < 8, you need to use @Param for named parameters, on JDK 8 or better, be sure to compile with -parameters.; nested exception is java.lang.IllegalArgumentException: Name for parameter binding must not be null or empty! On JDKs < 8, you need to use @Param for named parameters, on JDK 8 or better, be sure to compile with -parameters.
代码原型
@Query(value = "select w from Weibo w where w.user.username = :username")
List<Weibo> searchUserWeibo(@Param("username") String username);
正确写法
@Query(value = "select w from Weibo w where w.user.username = ?1")
List<Weibo> searchUserWeibo(@Param("username") String username);
原因分析
不能再用以前的 (:) 冒号语法 ,应该写成 (?)问号语法 ; 比如
@Query(value = “select w from Weibo w where w.user.username = ?1 and ?2 and ?3”)
List searchUserWeibo(@Param(“username”) String xx,@Param(“pwd”) String xxx,@Param(“tel”) String xxxx);