【问题标题】:org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join exeptionorg.hibernate.hql.internal.ast.QuerySyntaxException:连接异常的预期路径
【发布时间】:2019-12-21 17:17:14
【问题描述】:

我正在尝试使用 hibernate 编写 jpql 查询。我在@Repository 中有这样的查询

@Query(value = "select p from Product p inner join ProductsUser pu on p.prosuctId = pu.productId where pu.userId = :uuid")

但我得到一个例外

Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join! [select p from com.example.api.dto.ProductDto p inner join ProductsUsersDto pu on p.prosuctId = pu.productId where pu.userId = :uuid]

【问题讨论】:

    标签: java postgresql jpql


    【解决方案1】:

    您不需要指定JOIN ... ON-clause,因为它已经在实体类中进行了配置。所以查询要简单一些,像这样:

    @Query("select p from Product p join p.productsUser pu where pu.userId = :uuid")
    

    【讨论】:

      猜你喜欢
      • 2016-01-13
      • 2020-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-15
      • 1970-01-01
      相关资源
      最近更新 更多