Reputation: 4122
I am experimenting WSO2 DataService Component with MySQL as the database. I exposed the MySQL database as a service using the WSO2 component and was able to use the WSDL to generate Java code.
Using the Java CXF Client, I am able to connect to the database and perform the CRUD operations. The prime concern for me now is how WSO2 DSS Component handles Dirty Data. To test the scenario, I have the following code:
public class TestService{
//Code to connect to service
private void callInsertOperation(HermesCompleteServicePortType port) {
((BindingProvider) port).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
port.beginBoxcar();
port.insertOperation("Key1", "TestData", Double.valueOf(0.00));
try {
port.endBoxcar(null);
} catch (DataServiceFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Insert completed");
}
private void callUpdateOperation(HermesCompleteServicePortType port) {
((BindingProvider) port).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
port.beginBoxcar();
port.updateOperation("Key2", "TestData1", Double.valueOf(10.00));
try {
port.endBoxcar(null);
} catch (DataServiceFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Update completed");
}
}
The issue is in the update operation when the following conditions are true:
In these 2 cases, I would assume the DataService to indicate that the update operation failed/threw an exception/ did not affect any rows. But it does not give any indication and I also checked the wso2 logs to see if there was any message/exception related to this, but none appeared.
And obviously, the db table remains unchanged after the update operation.
How does WSO2 DSS handle these scenarios? How would the client know if the update operation was not successful? Am I missing something in the code?
EDIT I don't want to use Stored Procedures to check the count of result rows as mentioned here
Upvotes: 0
Views: 1045
Reputation: 81
Apparently, there is no such direct functionality in DSS to identify whether update operation affected any rows. Two scenarios that you have pointed, does not cause to SQLException. Those will execute as normal update operations even if we run through the mysql (database) command prompt. But it will show the result as affected rows= 0. With the current implementation of DSS, we do not return a failure message to client other than the execution does not get success, which is not the case here.
We will add this as a new feature to future release of DSS which will return the "updated row count" upon a particular query invocations like INSERT/UPDATE.
Upvotes: 2