Как передать параметр в Cassandra CQL-запрос в WSO2 DSS
Я пытался получить параметризованный запрос CQL, работающий в WSO2 DSS. К сожалению, у меня не получилось. Ценю вашу помощь, как только я застрял в срочном вопросе.
Ниже приводится содержание файла 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
СПАСИБО ЗА ВАШЕ ВРЕМЯ И ВАШУ ПОМОЩЬ
1 ответ
Решение
Я нашел решение. Я пропустил, чтобы иметь выходное сопоставление. Похоже, что нет выходного сопоставления, DSS принимает команду как команду обновления (см. http://docs.wso2.org/wiki/display/DSS301/Cassandra).