QuerySyntaxException:加入期望的路径!在不相关的表上的HQL查询中

时间:2013-09-26 12:11:02

标签: java hibernate hql

我有这些POJO课程

public class MapProxy implements Serializable {

    private Service service;
    private Application application;
    private Connector connector;

    //getter and setter
}

public class CategoryTranslator implements Serializable{

    private ArtCategory artCat;
    private ProviderCategory providerCat;
    private String provider;

    //gettere and setter
}

我在ArtCategory xml mapper中查询了一个来自serviceName和applicationName的ArtCategory

这里是查询

<query name="ArtCategory.getCategoryByServApp">
    SELECT DISTINCT cat_t.artCat
    FROM CategoryTranslator cat_t 
    INNER JOIN MapProxy mp WITH (cat_t.provider = mp.connector.provider.name)
    INNER JOIN mp.service ser WITH (ser.serviceName=:serviceName)
    INNER JOIN mp.application app WITH (app.applicationName=:applicationName)
</query>

当我执行此查询时,我收到了一个Hibernate异常:

11:52:55,485 ERROR [PARSER]  Invalid path: 'mp.application'
11:52:55,499 ERROR [SessionFactoryImpl] Error in named query: ArtCategory.getCategoryByServApp
org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!

[UPDATE]

此查询效果很好:

SELECT DISTINCT cat_t.artCat
FROM CategoryTranslator cat_t 
WHERE cat_t.provider='test'

在另一个xml映射器(MaxProxy)中,我有这个查询也很好用

<query name="MapProxy.getProxy_service_app">
    SELECT mp
    FROM MapProxy mp
    INNER JOIN mp.service srv WITH (srv.serviceName=:serviceName) 
    INNER JOIN mp.application app WITH (app.applicationName=:applicationName)   
</query>

为什么hiberante无法映射mp.application?我错了什么?

0 个答案:

没有答案