gpt4 book ai didi

java - org.hibernate.hql.internal.ast.QuerySyntaxException : Path expected for join exeption

转载 作者:行者123 更新时间:2023-11-29 14:26:14 30 4
gpt4 key购买 nike

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

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

但是我得到一个异常(exception)

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]

最佳答案

您不需要指定 JOIN ... ON 子句,因为它已在实体类中配置。所以查询有点简单,像这样:

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

关于java - org.hibernate.hql.internal.ast.QuerySyntaxException : Path expected for join exeption,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57506711/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com