Hibernate标准无法加入三个表。

时间:2015-07-28 06:37:06

标签: hibernate

我正在使用三个表,并希望返回三个表作为Object [],以便我可以将PM [0]检索为PMSP0200,将对象[1]检索为PMSPWC02,将对象[2]检索为PMSJUS01.Below是我的查询想要使用Criteria或HQL执行。它将错误作为点节点给出,没有左侧连接。只有在我加入第三张桌子时才会出现此错误。如果我只加入两个表,那么它工作正常。请使用标准或HQL回复优先级。我会感激你的。

Query query = session.getNamedQuery("PMSP0200DAO_selectPMSP0200AndPMSPWC02ById");
            query.setString("id02", id02);
            query.setString("location", location);
            query.setString("master0co", master0co);
            query.setString("policy0num", policy0num);
            query.setString("symbol", symbol);
            query.setString("module", module);
            query.setCharacter("trans0stat", trans0stat);

            List resultList = query.list();
            if (resultList != null && resultList.size() > 0) {
                Object rowResult = resultList.get(0);
                arrayRowResult = (Object[]) rowResult;
            } else {
                status.setSqlCode(DBAccessStatus.DB_EOF);
            }


HBM

<query name="PMSP0200DAO_selectPMSP0200AndPMSPWC02ById">

select Pmsp0200TO, Pmspwc02TO,Pmsjus01TO 
from com.csc.pt.svc.data.to.Pmsp0200TO Pmsp0200TO ,
com.csc.pt.svc.data.to.Pmspwc02TO Pmspwc02TO,
    com.csc.pt.svc.data.to.Pmsjus01TO Pmsjus01TO where

Pmsp0200TO.id.symbol = :symbol and
Pmsp0200TO.id.policy0num = :policy0num and
Pmsp0200TO.id.module = :module and
Pmsp0200TO.id.master0co = :master0co and
Pmsp0200TO.id.location = :location and
Pmsp0200TO.id.trans0stat = :trans0stat and
Pmsp0200TO.id.id02 = :id02 and

Pmsp0200TO.id.symbol =Pmspwc02TO.id.wc02Symbol and 
Pmsp0200TO.id.policy0num =Pmspwc02TO.id.wc02PolicyNo and 
Pmsp0200TO.id.module= Pmspwc02TO.id.wc02Module and 
Pmsp0200TO.id.master0co = Pmspwc02TO.id.wc02MasterCo and 
Pmsp0200TO.id.location =Pmspwc02TO.id.wc02Location  and
Pmsp0200TO.id.trans0stat=Pmspwc02TO.id.wc02Status  and


Pmsp0200TO.id.symbol =Pmsjus01TO.id.symbol and 
Pmsp0200TO.id.policy0num =Pmsjus01TO.id.policy0num and 
Pmsp0200TO.id.module= Pmsjus01TO.id.module and 
Pmsp0200TO.id.master0co = Pmsjus01TO.id.master0co and 
Pmsp0200TO.id.location =Pmsjus01TO.id.location                  
</query> 

0 个答案:

没有答案