Reputation: 279
I'm trying to write jpql query with hibernate. I have such query in @Repository
@Query(value = "select p from Product p inner join ProductsUser pu on p.prosuctId = pu.productId where pu.userId = :uuid")
But I get an 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]
Upvotes: 0
Views: 179
Reputation: 7521
You don't need to specify JOIN ... ON
-clause since it's already configured in Entity classes. So query is bit simpler, like this:
@Query("select p from Product p join p.productsUser pu where pu.userId = :uuid")
Upvotes: 2