简体   繁体   中英

Hibernate Exception

org.hibernate.hql.ast.QuerySyntaxException: cannot dereference scalar collection element: cspName

st.append("SELECT customers.name,sum(csp.cspValue) as TotalMoney ");
            st.append("from Account as account ");
            st.append("left join account.CSPFields as csp with ((account.accountID=csp.id) and  (csp.cspName = 'Target')) ");
            st.append("left join Customers as customers");
            st.append("with account.customerExec.id=customers.id ");
st.append("where (account.accountDate between :startDate and :endDate) ");
            st.append("and (account.accountBatch.id in (:acIDs)) ");
            st.append("group by customers.name");

CSPFields is object of map in Account class. cspName is key in map collection.

HQL is case sensitive where objects are concerned, is your ACCOUNT entity really all upper case? It might help if you posted your Customer and ACCOUNT entity.

could you try using elements(account.CSPFields). That should do the trick.

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