Announcement

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

    Access other datasource from a BasicDataSource

    Hi,

    I have a solution where I have two separate datasources that access the same database table.

    One datasource ds1, is used to search and retrieve data from this table, and is joined with a number of other tables with aggregated fields.

    The other datasource, ds2, is a BasicDatasource extension that is used for saving records.

    In executeAdd and executeUpdate in ds2, I need to detect what primary key d1 is using.

    So, I´m looking for a way to find the DataSource instance for ds1 in ds2? How can I access other datasources from a custom datasource?

    Regards
    Rolf

    #2
    Hi Rolf,

    I think you might be mixing serverside and clientside here. What are you trying to achieve?

    If it is that you want the (implicit) changes to DS1 be visible in the client when you update DS2, you'll need dsResponse.addRelatatedUpdate() on your DS2 response in your executeUpdate().

    If you want the server to "know" what the user selected in the GUI in DS1, I'm afraid that it might not be possible this way. If you want to do something like that you'll have to persist the selection from DS1 in the DB or send this information along with your request to DS2.

    Best regards,
    Blama

    Comment


      #3
      Thanks for the reply.

      My question is related to server side code. Basically, I have custom logic in a (generic) BasicDataSource implementation that need to retrieve some information about other defined datasources in the system based on the datasource name.

      I.e a server side method that returns a com.isomorphic.datasource.DataSource instance based on datasource name.

      (I´m already using addRelatedUpdate to keep DS1 and DS2 caches in sync on the client side, which works fine.)

      Anyway, I have been able to work my way around this problem by constructing a new DSRequest object and getting the datasource from there. However, its a hack, and a better way would be preferable.

      Thanks a lot.
      Rolf

      Comment


        #4
        Well, you'll need a DSRequest anyway, don't you?
        So I use:

        Code:
        DSRequest secondReq = new DSRequest("MYSECONDDS", DataSource.OP_FETCH, dsRequest.getRPCManager());
        Best regards,
        Blama

        Comment


          #5
          RPCManager.getDataSource() will get you a DataSource that is automatically freed at the end of the HTTP request cycle.

          DataSourceManager.getDataSource() will get you a DataSource that you must return to the pool yourself via free().

          If you are looking for the result of a previous operation in the queue, you may instead want RPCManager.findLastResponse().

          Comment


            #6
            Great

            RPCManager.getDataSource(String name) was exactly what I was looking for.

            Thanks

            Comment

            Working...
            X