why do I get Path expected for join when I use join key word in hql

前端 未结 2 2089
我寻月下人不归
我寻月下人不归 2021-02-10 19:34

I have the following HQL

String FIND_PRODUCT_CLASS_ID = \"SELECT pc.id FROM ProductClass pc\"+ 
\" JOIN ProductGroup pg ON pc.id = pg.productClassId\" +
\" JOIN         


        
相关标签:
2条回答
  • 2021-02-10 20:13

    Since Hibernate 5.1 you can join unrelated entities using SQL like syntax joins.

    In case you still get the antlr.SemanticException: Path expected for join! error you might have to use the full class name including the package e.g.

    String FIND_PRODUCT_CLASS_ID = "SELECT pc.id FROM ProductClass pc"+ 
    " JOIN com.mypackage.ProductGroup pg ON pc.id = pg.productClassId" +
    " JOIN com.mypackage.Product p ON pg.id = p.id" +
    " JOIN com.mypackage.ProductSub ps ON p.id = ps.productId WHERE ps.id =:childProductSubId";
    
    0 讨论(0)
  • 2021-02-10 20:28

    We need to provide path in HQL query. That's the "Path expected for join" the exception is coming.

    change query something like below: Please edit as per use

    String FIND_PRODUCT_CLASS_ID = "SELECT pc.id FROM ProductClass pc"+ 
    " JOIN pc.ProductGroup pg " +
    " JOIN pg.Product p " +
    " JOIN p.ProductSub ps WHERE ps.id =:childProductSubId";'
    

    Please refer this.

    0 讨论(0)
提交回复
热议问题