WSO2 Carbon
  1. WSO2 Carbon
  2. CARBON-7589

Problems occurred when I use field type for input of types: date, timestamp and int and I try passed "null" in value.

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Highest Highest
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.1.0
    • Component/s: None
    • Labels:
      None
    • Environment:
          Ubuntu 10.04, Java 6

      Description

      My problems occurred when I use field type for input of types: date, timestamp and int and I try passed "null" in value.

      In attachment my service, mysql dump and patch to correction.

      Erros recevieds in log:
      === with all fields "NULL"
      Name: Products
      Location: /home/lsaraiva/Applications/wso2/wso2dataservices-2.5.0/repository/deployment/server/dataservices/Products.dbs
      Description: N/A
      Default Namespace: http://ws.wso2.org/dataservice
      Current Request Name: selectProduct
      Current Params: {id=null, updated_at=null, name=null, created_at=null, quantity=null}
      Nested Exception:-
      java.lang.NumberFormatException: For input string: "null"
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         at java.lang.Integer.parseInt(Integer.java:449)
         at java.lang.Integer.parseInt(Integer.java:499)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.setIntValue(SQLQuery.java:1329)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.setParamInPreparedStatement(SQLQuery.java:832)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.createProcessedPreparedStatement(SQLQuery.java:813)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.processNormalQuery(SQLQuery.java:471)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.runQuery(SQLQuery.java:1411)
         at org.wso2.carbon.dataservices.dispatch.query.Query.execute(Query.java:214)
         at org.wso2.carbon.dataservices.dispatch.CallQuery.execute(CallQuery.java:154)
         at org.wso2.carbon.dataservices.dispatch.CallQueryGroup.execute(CallQueryGroup.java:108)
         at org.wso2.carbon.dataservices.dispatch.operation.Operation.execute(Operation.java:63)
         at org.wso2.carbon.dataservices.dispatch.DataService.invoke(DataService.java:327)
         at org.wso2.carbon.dataservices.dispatch.DSOMDataSource.serialize(DSOMDataSource.java:90)

      === with id = 1 and other all fields "NULL"
      Name: Products
      Location: /home/lsaraiva/Applications/wso2/wso2dataservices-2.5.0/repository/deployment/server/dataservices/Products.dbs
      Description: N/A
      Default Namespace: http://ws.wso2.org/dataservice
      Current Request Name: selectProduct
      Current Params: {id=1, updated_at=null, name=null, created_at=null, quantity=null}
      Nested Exception:-
      java.lang.RuntimeException: In valid string to parse
         at org.apache.axis2.databinding.utils.ConverterUtil.convertToDate(ConverterUtil.java:603)
         at org.wso2.carbon.dataservices.DBUtils.getDate(DBUtils.java:521)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.setDateValue(SQLQuery.java:995)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.setParamInPreparedStatement(SQLQuery.java:851)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.createProcessedPreparedStatement(SQLQuery.java:813)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.processNormalQuery(SQLQuery.java:471)
         at org.wso2.carbon.dataservices.dispatch.query.SQLQuery.runQuery(SQLQuery.java:1411)
         at org.wso2.carbon.dataservices.dispatch.query.Query.execute(Query.java:214)
         at org.wso2.carbon.dataservices.dispatch.CallQuery.execute(CallQuery.java:154)
         at org.wso2.carbon.dataservices.dispatch.CallQueryGroup.execute(CallQueryGroup.java:108)
         at org.wso2.carbon.dataservices.dispatch.operation.Operation.execute(Operation.java:63)
         at org.wso2.carbon.dataservices.dispatch.DataService.invoke(DataService.java:327)
         at org.wso2.carbon.dataservices.dispatch.DSOMDataSource.serialize(DSOMDataSource.java:90)
      1. Products.dbs
        4 kB
        Leonardo Saraiva
      2. products.sql
        2 kB
        Leonardo Saraiva
      3. wso2-dataservices-accept-null.patch
        1 kB
        Leonardo Saraiva

        Activity

        Hide
        Anjana Fernando
        added a comment -
        Hi Leonardo,

        First of all, thank you for reporting the issue and for providing a patch. But your patch cannot be applied because, it is not the correct approach in handling null values. This is fixed by checking for the "xsi:nil" attribute in the input elements and setting the null values appropriately. This can be checked by using a codegen client stub, and passing a null object to the operation's parameters.

        When testing this, tryit cannot be used to pass null values, when you don't enter a value for field, it altogether doesn't create a parameter element in the message. Also the null values are now supported for output element/attributes as well.

        Cheers,
        Anjana.
        Show
        Anjana Fernando
        added a comment - Hi Leonardo, First of all, thank you for reporting the issue and for providing a patch. But your patch cannot be applied because, it is not the correct approach in handling null values. This is fixed by checking for the "xsi:nil" attribute in the input elements and setting the null values appropriately. This can be checked by using a codegen client stub, and passing a null object to the operation's parameters. When testing this, tryit cannot be used to pass null values, when you don't enter a value for field, it altogether doesn't create a parameter element in the message. Also the null values are now supported for output element/attributes as well. Cheers, Anjana.
        Hide
        Anjana Fernando
        added a comment -
        Also, in the case of providing default values for query parameters, to provide null as the default value, a special variable "#{NULL}" can be used.
        Show
        Anjana Fernando
        added a comment - Also, in the case of providing default values for query parameters, to provide null as the default value, a special variable "#{NULL}" can be used.
        Hide
        Leonardo Saraiva
        added a comment - - edited
        But, in version 2.2.1 of Data Service, this action worked normaly. Those incompatibilities cause delay in updating versions.

        Thank you for help.
        Show
        Leonardo Saraiva
        added a comment - - edited But, in version 2.2.1 of Data Service, this action worked normaly. Those incompatibilities cause delay in updating versions. Thank you for help.

          People

          • Assignee:
            Anjana Fernando
            Reporter:
            Leonardo Saraiva
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: