Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem adding two rows at once with serverside DSRequest

    Hi Isomorphic,

    I am trying to add two rows at once in current 5.1p with a List feeded to serverside dsRequest.setValues():

    Code excerpt:
    Code:
            List<Map<String, Object>> productEntries = getLeadProductList(request.getValues(), newLeadId);
            if (productEntries.size() > 0) {
                DSRequest leadProductAddRequest = new DSRequest(ServerDatasourceEnum.T_LEAD_PRODUCTINTEREST.getValue(), DataSource.OP_ADD,
                        request.getRPCManager());
                leadProductAddRequest.setValues(productEntries);
    
                DSResponse leadProductAddResponse = leadProductAddRequest.execute();
                if (leadProductAddResponse.statusIsError())
                    return new DSResponse().setFailure(String.format(I18n.getString("errorWritingProductDataForRow", servletRequest), currentRow));
            }
    productEntries is this (displayed in Eclipse debug mode):
    Code:
    [{LEAD_ID=2773, ISFILTER=false, PRODUCT_ID=29}, {LEAD_ID=2773, ISFILTER=false, PRODUCT_ID=32}]
    I have built a similar testcase for supplyItem, but it is working there, so I'm a bit confused now.
    In my application, when stepping through the program, I get this in the server log after leadProductAddRequest.execute():
    Code:
    === 2016-04-05 01:21:55,759 [c-10] WARN  DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
    [B]=== 2016-04-05 01:21:55,760 [c-10] WARN  DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
    === 2016-04-05 01:21:55,761 [c-10] WARN  DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
    === 2016-04-05 01:21:55,762 [c-10] WARN  DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
    === 2016-04-05 01:21:55,763 [c-10] WARN  DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
    === 2016-04-05 01:21:55,764 [c-10] WARN  DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
    === 2016-04-05 01:21:55,764 [c-10] WARN  DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
    === 2016-04-05 01:21:55,765 [c-10] WARN  DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.[/B]
    === 2016-04-05 01:21:55,766 [c-10] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2016-04-05 01:21:55,767 [c-10] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2016-04-05 01:21:55,775 [c-10] WARN  DSRequest - [builtinApplication.null] getValues() called on dsRequest containing multiple sets of values, returning first in list.
    === 2016-04-05 01:21:55,788 [c-10] INFO  SQLDataSource - [builtinApplication.null] Performing add operation with
        criteria: {CREATED_BY:"1083",MODIFIED_AT:new Date(1459812075960),LEAD_ID:2773,ISFILTER:false,CREATED_AT:new Date(1459812075960),MODIFIED_BY:"1083",PRODUCT_ID:"29"}    values: {CREATED_BY:"1083",MODIFIED_AT:new Date(1459812075960),LEAD_ID:2773,ISFILTER:false,CREATED_AT:new Date(1459812075960),MODIFIED_BY:"1083",PRODUCT_ID:29,TENANT_ID:1}
    === 2016-04-05 01:21:55,792 [c-10] DEBUG SQLValuesClause - [builtinApplication.null] Sequences: {ID=__default}
    === 2016-04-05 01:21:55,798 [c-10] DEBUG SQLDataSource - [builtinApplication.null] Setting DSRequest as being part of a transaction
    === 2016-04-05 01:21:55,799 [c-10] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'Oracle' using connection '662124990': INSERT INTO T_LEAD_PRODUCTINTEREST (CREATED_AT, CREATED_BY, ISFILTER, LEAD_ID, MODIFIED_AT, MODIFIED_BY, PRODUCT_ID, TENANT_ID, ID) VALUES (TO_DATE('2016-04-05 01:21:15','YYYY-MM-DD HH24:MI:SS'), '1083', 'N', 2773, TO_DATE('2016-04-05 01:21:15','YYYY-MM-DD HH24:MI:SS'), '1083', 29, 1, T_LEAD_PRODUCTINTEREST_ID.NextVal)
    === 2016-04-05 01:21:55,803 [c-10] DEBUG SQLDriver - [builtinApplication.null] SequenceMode is not JDBC_DRIVER, skipping search for generated values
    === 2016-04-05 01:21:55,803 [c-10] DEBUG SQLDataSource - [builtinApplication.null] add operation affected 1 rows
    === 2016-04-05 01:21:55,804 [c-10] DEBUG SQLDataSource - [builtinApplication.null] Setting DSRequest as being part of a transaction
    === 2016-04-05 01:21:55,804 [c-10] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'Oracle' using connection '662124990': SELECT T_LEAD_PRODUCTINTEREST_ID.CurrVal FROM DUAL
    === 2016-04-05 01:21:55,806 [c-10] INFO  SQLDataSource - [builtinApplication.null] primaryKeys: {ID=2573}
    === 2016-04-05 01:21:55,807 [c-10] DEBUG AppBase - [builtinApplication.null, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2016-04-05 01:21:55,808 [c-10] DEBUG AppBase - [builtinApplication.null, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2016-04-05 01:21:55,813 [c-10] INFO  SQLDataSource - [builtinApplication.null, builtinApplication.null] Performing fetch operation with
        criteria: {TENANT_ID:1,ID:"2573"}    values: {TENANT_ID:1,ID:"2573"}
    === 2016-04-05 01:21:55,816 [c-10] INFO  SQLDataSource - [builtinApplication.null, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
    === 2016-04-05 01:21:55,818 [c-10] DEBUG SQLDataSource - [builtinApplication.null, builtinApplication.null] JDBC driver windowed select rows 0->-1, result size 1. Query: SELECT T_LEAD_PRODUCTINTEREST.ID, T_LEAD_PRODUCTINTEREST.TENANT_ID, T_LEAD_PRODUCTINTEREST.CREATED_BY, T_LEAD_PRODUCTINTEREST.CREATED_AT, T_LEAD_PRODUCTINTEREST.MODIFIED_BY, T_LEAD_PRODUCTINTEREST.MODIFIED_AT, T_LEAD_PRODUCTINTEREST.LEAD_ID, T_LEAD_PRODUCTINTEREST.PRODUCT_ID, T_LEAD_PRODUCTINTEREST.ISFILTER FROM T_LEAD_PRODUCTINTEREST WHERE (T_LEAD_PRODUCTINTEREST.TENANT_ID=1 AND T_LEAD_PRODUCTINTEREST.ID=2573)
    === 2016-04-05 01:21:55,818 [c-10] DEBUG SQLDataSource - [builtinApplication.null, builtinApplication.null] Setting DSRequest as being part of a transaction
    === 2016-04-05 01:21:55,820 [c-10] DEBUG SQLDataSource - [builtinApplication.null, builtinApplication.null] Using paging strategy 'jdbcScroll' - scrolling to absolute position 1
    === 2016-04-05 01:21:55,822 [c-10] DEBUG SQLDataSource - [builtinApplication.null, builtinApplication.null] Scrolling / positioning took 2ms
    === 2016-04-05 01:21:55,824 [c-10] INFO  DSResponse - [builtinApplication.null] DSResponse: List with 1 items
    === 2016-04-05 01:21:55,824 [c-10] INFO  DSResponse - DSResponse: List with 1 items
    So as you can see, it is working, but only adding 1 row, instead of 2.
    I do not know where this warning above comes from - it does not happen in the testcase (did not include it, as it is working there).

    Could you look up what triggers the warning? I can then either fix my usage or make the testcase fail as well.

    Thank you & Best regards
    Blama

    #2
    We can't really "look up" what causes the warning, because we'd have to have actual running code so that we could see the stack trace that leads to the getValues() call.

    But at a high level, if you have multiple records to insert, use two (or more) DSRequests - the ability to use an Array as a value set exists for certain internal purposes but isn't supported for application code.

    Comment


      #3
      Hi Isomorphic,

      OK, will do so. Please note that the docs for setValue() currently mention that this would be possible.
      Sets the values for this DSRequest. You may pass either a Map or a List of Maps. The List type is typically used for a DataSource.OP_ADD operation with multiple records.
      What I meant (which does not matter now as I can easily change my code to use 2 DSRequests) was that you look up the if-clause before you log-warn the message.

      Thank you & Best regards
      Blama

      Comment


        #4
        The if clause just recapitulates the message - dsRequest.getValues() was called when multiple values are present, so just the first set was returned.

        Comment


          #5
          Hi Isomorphic,

          OK, understood what you meant with "see the stack trace that leads to the getValues() call" right after hitting "Post reply".
          Everything clear now besides the docs.

          Best regards
          Blama

          Comment

          Working...
          X