简体   繁体   中英

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

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]

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM