开发者社区 问答 正文

spring-jpa-data?报错

@Query(value="select ? from tt where ? is not null")

List<String> finddd(@Param("dd")String dd);

传的参数可以直接填入 问号处吗?

同一参数在sql中使用多次,还可以直接使用@Query注解吗?

select :dd from tt where :dd is not null这样虽然不报错,但是返回值为所传参。

请大神帮忙!

展开
收起
爱吃鱼的程序员 2020-06-07 21:47:53 576 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
    @Query(value="select (:dd) from tt where (:dd) is not null")
    List<String> finddd(@Param("dd")String dd);

    跟Hibernate一样参数用 :ParamName 就行 

                            我试过怎么做不报错,但sql返回的值不一致。例如type="gh",返回{“gh”}
    
    2020-06-07 21:48:12
    赞同 展开评论
问答分类:
SQL
问答标签:
问答地址: