2 Replies Latest reply on Mar 14, 2009 6:11 AM by gonorrhea

    Seam EntityQuery and multiple data sources

    paulmkeogh

      After an unbelieveable amount of hassle and a day on Google, I've finally got a working and deployed application that includes 2 data sources to 2 geographically disparate DBs, 2 PUs, the correct components.xml and web views against entities from both DBs. So far so good.


      Now I need to construct a query across both schemas - can I use Seam EntityQuery for this ?
      If so, any pointers as to how ?


      If not, any suggestions as to best practice in Seam to accomplish this ?


      Thanks,

        • 1. Re: Seam EntityQuery and multiple data sources
          trouby

          You can have two different EntityQueries,



          In your class that extends EntityQuery, you can override


          @Override
             protected String getPersistenceContextName()
             {
                return "your_2nd_persistence_context_name";
             }
          





          Asaf.

          • 2. Re: Seam EntityQuery and multiple data sources
            gonorrhea

            if you want to read data (i.e. SELECT) from more than one db on multiple db servers in one query, you have the following options:


            1) use a product like jboss metamatrix or teiid
            2) use a stored proc with four part naming convention to span multiple servers (e.g. SERVER01.fooDB.dbo.barTable)
            3) use a native query