Synapse
  1. Synapse
  2. SYNAPSE-533

DBLookup extracs only first element from database

    Details

      Description

      I just realized that the DBLookup mediator extracts only the first row... when i try to use statement like select * from mytable; and if my table called as mytable contains 3 values like test1, test2 and test 3, when i try to use the same only first element gets displayed ie like test1 and i dont get output as test1,test2, test3. DBLookup needs to improve this to extract multiple rows if there are multiple rows, in which case the result set will be a list of results which might be a special list that needs to be implement because it can get a XML representation of this list easily.

      Refer discussion at link : http://wso2.org/forum/thread/5181

      1. SYNAPSE-533.patch
        22 kB
        Rajika Kumarasiri

        Activity

        Hide
        Hiranya Jayathilaka added a comment -

        Hi Max,

        I had a quick look and the code seems to be correct. However, you might want to think about the case where the select query returns a very large number of rows. You might want to add some optional mechanisms to prevent an out of memory error in such situations. Other than that, it looks good to me.

        -Hiranya

        Show
        Hiranya Jayathilaka added a comment - Hi Max, I had a quick look and the code seems to be correct. However, you might want to think about the case where the select query returns a very large number of rows. You might want to add some optional mechanisms to prevent an out of memory error in such situations. Other than that, it looks good to me. -Hiranya
        Hide
        Max Nikolenko added a comment -

        Hi,

        I tried to implement my own mediator for selecting multiple records from DB:
        https://github.com/mephist/wso2-esb-dbselect

        I wish if somebody test it and give me some feedback.

        Thanks.

        Show
        Max Nikolenko added a comment - Hi, I tried to implement my own mediator for selecting multiple records from DB: https://github.com/mephist/wso2-esb-dbselect I wish if somebody test it and give me some feedback. Thanks.
        Hide
        Yusuf Khan added a comment -

        Hi ,

        Is there any update or alternate to be provided for this issue?

        Thanks,
        Yusuf

        Show
        Yusuf Khan added a comment - Hi , Is there any update or alternate to be provided for this issue? Thanks, Yusuf
        Hide
        Nirmal Fernando added a comment -

        Hi,

        I am a newbie to Apache Synapse! Would this bug suitable for a newbie?

        Thanks.

        Show
        Nirmal Fernando added a comment - Hi, I am a newbie to Apache Synapse! Would this bug suitable for a newbie? Thanks.
        Hide
        Rajika Kumarasiri added a comment -

        Hiranya,
        Yeah it seems wrapping the result set in a XML seems like a good solution.

        Rajika

        Show
        Rajika Kumarasiri added a comment - Hiranya, Yeah it seems wrapping the result set in a XML seems like a good solution. Rajika
        Hide
        Hiranya Jayathilaka added a comment -

        Rajika,

        I don't think this is a very good solution to the problem at hand. For instance how can one find out the number of records returned by the query at the configuration development time? I think we need to look for a different solution. May be an option to publish the result set as an XML is a more elegant solution.

        Thanks,
        Hiranya

        Show
        Hiranya Jayathilaka added a comment - Rajika, I don't think this is a very good solution to the problem at hand. For instance how can one find out the number of records returned by the query at the configuration development time? I think we need to look for a different solution. May be an option to publish the result set as an XML is a more elegant solution. Thanks, Hiranya
        Hide
        Shibu Gope added a comment -

        Is this bugfix released in version 1.2?

        Show
        Shibu Gope added a comment - Is this bugfix released in version 1.2?
        Hide
        Rajika Kumarasiri added a comment -

        Here is a patch which fix the problem.
        Now the result element has an optional rowIndex attribute which you can specify the row of the result set to get the required result when there are more than one entry.
        ex:
        <result name="company_id" column="id" />
        <result name="company_price_0" column="price" rowIndex="2"/>
        <result name="company_price_1" column="price" rowIndex="4"/>

        Rajika

        Show
        Rajika Kumarasiri added a comment - Here is a patch which fix the problem. Now the result element has an optional rowIndex attribute which you can specify the row of the result set to get the required result when there are more than one entry. ex: <result name="company_id" column="id" /> <result name="company_price_0" column="price" rowIndex="2"/> <result name="company_price_1" column="price" rowIndex="4"/> Rajika
        Hide
        Rajika Kumarasiri added a comment -

        hi,
        I think we have an alternative for this. Setting the whole result set as the msg_ctx property would be problematic if the result set is huge. So i suggest adding a new attribute row index for the result element if we have multiple entries.

        -Rajika

        Show
        Rajika Kumarasiri added a comment - hi, I think we have an alternative for this. Setting the whole result set as the msg_ctx property would be problematic if the result set is huge. So i suggest adding a new attribute row index for the result element if we have multiple entries. -Rajika
        Hide
        Rajika Kumarasiri added a comment -

        hi,
        I think we have an alternative for this. Setting the whole result set as the msg_ctx property would be problematic if the result set is huge. So i suggest adding a new attribute row index for the result element if we have multiple entries.

        -Rajika

        Show
        Rajika Kumarasiri added a comment - hi, I think we have an alternative for this. Setting the whole result set as the msg_ctx property would be problematic if the result set is huge. So i suggest adding a new attribute row index for the result element if we have multiple entries. -Rajika
        Hide
        Ruwan Linton added a comment -

        Rajika, I think it is better to register this as a different extension to the SynapseXPathFunctionContext, may be called get-result(), please have a look at the way that the get-property function has been registered on the SynapseXPath and write a new class called GetResultFunction to provide this functionality.

        Show
        Ruwan Linton added a comment - Rajika, I think it is better to register this as a different extension to the SynapseXPathFunctionContext, may be called get-result(), please have a look at the way that the get-property function has been registered on the SynapseXPath and write a new class called GetResultFunction to provide this functionality.
        Hide
        Rajika Kumarasiri added a comment -

        I suggest we set the whole result set as a message context property and we provide another XPath extension function for GetPropertyFunction.java class to retrieve the required information form the results set, passing row and the column index to the function.

        Show
        Rajika Kumarasiri added a comment - I suggest we set the whole result set as a message context property and we provide another XPath extension function for GetPropertyFunction.java class to retrieve the required information form the results set, passing row and the column index to the function.

          People

          • Assignee:
            Hiranya Jayathilaka
            Reporter:
            minal sontakke
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 96h
              96h
              Remaining:
              Remaining Estimate - 96h
              96h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development