Announcement

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

    Exception -- Fetched multiple results when trying single

    hi,

    i have a problem with the method DataSource.fetchSingle().

    Code:
    DataSource dataSource = DataSourceManager.get("supplyItem");
    dataSource.fetchSingle("units", "Roll");
    According to the javadoc, I would expect that only the first record is returned. So "fetch first row only" but I get the following exception.

    Code:
    === 2013-08-12 17:53:22,559 [l0-6] DEBUG SQLDriver - [builtinApplication.null] About to execute SQL query in 'HSQLDB' using connection '769859113'
    === 2013-08-12 17:53:22,560 [l0-6] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'HSQLDB': SELECT supplyItem.SKU, supplyItem.category, supplyItem.description, supplyItem.inStock, supplyItem.itemID, supplyItem.itemName, supplyItem.nextShipment, supplyItem.unitCost, supplyItem.units FROM supplyItem WHERE (supplyItem.units='Roll')
    === 2013-08-12 17:53:22,634 [l0-6] INFO  DSResponse - [builtinApplication.null] DSResponse: List with 75 items
    === 2013-08-12 17:53:22,635 [l0-6] DEBUG SQLDriver - Freeing SQLDriver dbConnection 769859113
    === 2013-08-12 17:53:22,636 [l0-6] DEBUG SQLConnectionManager - About to close JDBCConnection with hashcode "769859113"
    [WARN] /customds//supplyItemOperations.rpc
    java.lang.Exception: Fetched multiple results when trying single
    	at com.isomorphic.datasource.DataSource.forceSingle(DataSource.java:2982)
    	at com.isomorphic.datasource.DataSource.fetchSingle(DataSource.java:2874)
    	at com.smartgwt.sample.server.SupplyItemOperationsController.handleRequest(SupplyItemOperationsController.java:35)

    best regards,
    mirko

    i used: Isomorphic SmartClient/SmartGWT Framework (v9.0p_2013-08-09/PowerEdition Deployment 2013-08-09)

    #2
    From your snippet it looks like you're seeing this on the "supplyItem" dataSource. Can you clarify whether this is one of the unmodified dataSources from one of our shipped samples (and if so, which one).
    If you you have any custom server logic in place (overrides to the dataSource, DMI, etc), we'll probably need to see it in order to determine what's going on.

    Thanks
    Isomorphic Software

    Comment


      #3
      ohh sorry.
      I have this code simply inserted at the beginning of the class SupplyItemOperationsController.java in your "CustomDS" example. But it occurs with every SQLDataSource (standalone and inside servlet container)
      Last edited by ex70375; 12 Aug 2013, 10:21.

      Comment


        #4
        We'll clarify the docs to say that fetchSingle() actually throws an error if more than one result is returned.

        If you don't want this check, use fetch().

        Comment


          #5
          ok thank you.
          I thought you have implemented this SQL:

          FETCH FIRST clause
          http://en.wikipedia.org/wiki/Select_(SQL)#FETCH_FIRST_clause

          Comment


            #6
            If you'd like to do something like that, use a DSRequest with startRow:0 endRow:1 and the appropriate DB-specific SQL will be generated to ask the DB for the only the requested rows.

            Comment


              #7
              that sounds good. perfect. thank you.

              Comment

              Working...
              X