2012-12-27 57 views
2

我一直在嘗試獲取在WSO2 DSS中工作的參數化CQL查詢。不幸的是,我一直不成功。感謝您的幫助,因爲我被困在緊急事件中。如何將參數傳遞給WSO2 DSS中的Cassandra CQL查詢

以下是DBS文件內容

<data name="CassParamTest"> 
    <config id="CassDs"> 
     <property name="org.wso2.ws.dataservice.protocol">jdbc:cassandra://localhost:9161/oneDataAux</property> 
     <property name="org.wso2.ws.dataservice.driver">org.apache.cassandra.cql.jdbc.CassandraDriver</property> 
    </config> 
    <query id="getEmps" useConfig="CassDs"> 
     <sql>select employeeNumber from EMPLOYEES where employeeNumber = :employeeNumber</sql> 
     <param name="employeeNumber" sqlType="STRING" /> 
    </query> 
    <operation name="getEmps"> 
     <call-query href="getEmps"> 
     <with-param name="employeeNumber" query-param="employeeNumber" /> 
     </call-query> 
    </operation> 
</data> 

其實參數employeeNumber是一個數字。但我不斷收到錯誤。所以我也試圖用String也無濟於事。我也試過了?而不是命名參數

這是我得到的錯誤。

當參數是一個字符串,

<soapenv:Fault xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:axis2ns12="http://ws.wso2.org/dataservice"> 
    <soapenv:Code> 
     <soapenv:Value>axis2ns12:DATABASE_ERROR</soapenv:Value> 
    </soapenv:Code> 
    <soapenv:Reason> 
     <soapenv:Text xml:lang="en-US" xmlns:xml="http://www.w3.org/XML/1998/namespace">DS Fault Message: Error in DS non result invoke. 
DS Code: DATABASE_ERROR 
Nested Exception:- 
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processNormalQuery' 
DS Code: DATABASE_ERROR 
Source Data Service:- 
Name: CassParamTest 
Location: /CassParamTest.dbs 
Description: N/A 
Default Namespace: http://ws.wso2.org/dataservice 
Current Request Name: getEmps 
Current Params: {employeeNumber=1002} 
Nested Exception:- 
java.sql.SQLNonTransientException: No Update Count was returned from the CQL statement passed in an 'executeUpdate()' method 

</soapenv:Text> 
    </soapenv:Reason> 
    <soapenv:Detail> 
     <axis2ns11:DataServiceFault xmlns:axis2ns11="http://ws.wso2.org/dataservice">DS Fault Message: Error in DS non result invoke. 
DS Code: DATABASE_ERROR 
Nested Exception:- 
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processNormalQuery' 
DS Code: DATABASE_ERROR 
Source Data Service:- 
Name: CassParamTest 
Location: /CassParamTest.dbs 
Description: N/A 
Default Namespace: http://ws.wso2.org/dataservice 
Current Request Name: getEmps 
Current Params: {employeeNumber=1002} 
Nested Exception:- 
java.sql.SQLNonTransientException: No Update Count was returned from the CQL statement passed in an 'executeUpdate()' method 

</axis2ns11:DataServiceFault> 
    </soapenv:Detail> 
</soapenv:Fault> 

當參數是一個數字,

DS Code: DATABASE_ERROR 
Nested Exception:- 
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processNormalQuery' 
DS Code: DATABASE_ERROR 
Source Data Service:- 
Name: CassParamTest 
Location: /CassParamTest.dbs 
Description: N/A 
Default Namespace: http://ws.wso2.org/dataservice 
Current Request Name: getEmps 
Current Params: {employeeNumber=1002} 
Nested Exception:- 
java.sql.SQLException: Mismatched types: java.math.BigInteger cannot be cast to java.lang.String 

謝謝您的時間和你的幫助

回答

5

我找到了解決方案。我錯過了一個輸出映射。似乎如果輸出映射不存在,DSS將該命令作爲更新命令(請參閱http://docs.wso2.org/wiki/display/DSS301/Cassandra

+3

是的,這是正確的。在內部執行什麼類型的查詢的決定是通過檢查查詢是否具有結果與否 –