Announcement

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

    Proper DSResponse for an empty fetch?

    I was wondering what the proper DSResponse should be when an empty fetch is performed?

    I set the startRow, endRow and totalRows all to 0.

    What should be set for the Data via the setData api?

    Do I set anything, or null, or an empty List say via Collections.EMPTY_LIST?

    Thanks.

    #2
    An empty List would be the most correct, all 3 possibilities you list are correctly handled.

    Comment


      #3
      Thanks, I am currently setting it to an empty list. I just wanted to make sure I was setting it properly in order to avoid any potential problems.

      Comment


        #4
        I have just update our ds.xml to add an includeFrom field and reference it as the displayField via:
        Code:
        <field name="calendarName" includeFrom="calendar.name"/> 
        <field name="calendar" foreignKey="calendar.id" displayField="calendarName" type="text"/>
        The calendar name gets fetched ok when I have records but when I have no records to return for the list I get the following exception when I use an empy list:
        Code:
        2014-05-16-13:50:20:661 -0400   WARN [http-bio-8080-exec-8] dsRequest.execute() failed: 
        java.lang.IndexOutOfBoundsException: Index: 0
        	at java.util.Collections$EmptyList.get(Collections.java:3212)
        	at com.isomorphic.datasource.DSRequest.applyManualFilterAndSort(DSRequest.java:5311)
        	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2567)
        	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:215)
        and if set the data to null instead I get this exception:
        Code:
        2014-05-16-13:54:09:856 -0400   WARN [http-bio-8080-exec-4] dsRequest.execute() failed: 
        java.lang.NullPointerException
        	at com.isomorphic.datasource.DSRequest.applyRelatedDSRequest(DSRequest.java:5040)
        	at com.isomorphic.datasource.DSRequest.fetchRelatedValues(DSRequest.java:4929)
        	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2566)
        	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:215)
        Anything I should try?

        Thanks

        Code Level: SmartClient Version: v9.1p_2014-05-15/Pro Deployment (built 2014-05-15)

        Using custom data source implementation.

        Comment


          #5
          Sigh. The code already handles the result of get(0) returning null, but of course since this is Java, an exception is thrown instead. We'll revise this.

          Just a note that, since what you're doing here is effectively requesting the equivalent of a SQL JOIN across two different DataSource types where no native SQL is possible, the server framework is doing the equivalent of a SQL join in memory in Java.

          This is not fast. Just wanted to make sure you're aware.

          Comment


            #6
            Good point about the SQL Join.

            I think I can do the join myself and then I can make the subsequent call to fetchRelatedValues bascially avoid the extra lookup since I will have the displayName. I am pretty sure I can make that work for me.

            Thanks for pointing that out.

            Comment


              #7
              You can find this problem fixed in next nightly build.

              Comment


                #8
                Thanks works fine now.

                Comment

                Working...
                X