如何在@query存储库中获取@param的大小JPA

发布于 2025-01-23 10:06:34 字数 928 浏览 0 评论 0原文

我有一个问题,这是我想知道 @param 的大小,我传递给 @query ,但它在编译时给我以下错误:

unexpected token: : near line 1

我向您显示我的查询的代码:

  @Query(
  value = "SELECT DISTINCT company "
      + " FROM Company company "
      + " left join  company.companyProducts products "
      + " inner join  empresa.servicios services "
      + "   WHERE services.idService IN (:idsServices) "
      + "   AND products.id.idProduct IS NOT NULL "
      + "   AND ( (:idsProducts IS NOT NULL AND  COUNT(:idsProducts)>0)"
      + ") OR productos.id.idProduct IN (:idsProducts)) ")
  List<EmpresaGrupo> obtenerEmpresasProductoServicio(@Param("idsProducts") List<Integer> 
  idsProducts,
  @Param("idsServices") List<Integer> idsServices);

错误在我进行@Param的计数的位置直接跳跃:

(:idsProducts IS NOT NULL AND  COUNT(:idsProducts)>0)

感谢您的帮助

I have a question and it is that I want to know the size of a @Param that I pass to the @Query but it gives me the following error when compiling:

unexpected token: : near line 1

I show you the code of my query:

  @Query(
  value = "SELECT DISTINCT company "
      + " FROM Company company "
      + " left join  company.companyProducts products "
      + " inner join  empresa.servicios services "
      + "   WHERE services.idService IN (:idsServices) "
      + "   AND products.id.idProduct IS NOT NULL "
      + "   AND ( (:idsProducts IS NOT NULL AND  COUNT(:idsProducts)>0)"
      + ") OR productos.id.idProduct IN (:idsProducts)) ")
  List<EmpresaGrupo> obtenerEmpresasProductoServicio(@Param("idsProducts") List<Integer> 
  idsProducts,
  @Param("idsServices") List<Integer> idsServices);

The error jumps right where I do the Count of the @Param:

(:idsProducts IS NOT NULL AND  COUNT(:idsProducts)>0)

Thanks for help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文