Announcement

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

    Multi tenant datasource with SmartGWT Power

    Hello all,

    Is there a good getting started point for setting up a multi tenant application using JPA? I have the normal concerns of ensuring that accounts cannot see or touch data from other accounts. From what I'm reading we would use SQL templates but I want to ensure that this is the proper direction. If it's the right direction is there a good example to get started with?

    #2
    We recommend SQLDataSource rather than JPA, as it's faster, more powerful, more flexibile, takes less effort and is simpler. In particular, since you mentioned SQL templating, note that this is a feature of SQLDataSource that doesn't work with JPA.

    As far as multi-tenancy, this example shows something similar - users that cannot see each other's data in a shopping cart. The multi-tenancy requirement is meant by the DMI shown in that sample. Note that the sample shows SQL templating used for a join, but this is no longer necessary - the same join can now be achieved via dataSourceField.includeFrom.

    Comment


      #3
      The main workflow I'm thinking is the user logs into my application and userid is set in session. Then all resulting queries to the datasource will have "accountID = ${session.accountID}". Can you point me to the documentation for this?

      I'm still going to need JPA for some background tasks that my application will be performing but I think that this will work nicely. I'll just maintain a set of models that will be used by my background tasks and use a SQLDataSource for SmartGWT

      To make sure I understand your suggestions. Here is what you are suggesting / what I need to do.

      1.) Copy my connection information from persistence.xml to server.properties
      2.) Change my JPADatasources to SQLDataSources
      3.) Add a filter to all the datasources to sandbox a user to their account.
      4.) $$$$

      Comment


        #4
        Ahh sorry I didn't fully read the source for that example. It does exactly what I want. Thanks!

        Comment


          #5
          On this:

          I'm still going to need JPA for some background tasks that my application will be performing but I think that this will work nicely. I'll just maintain a set of models that will be used by my background tasks and use a SQLDataSource for SmartGWT
          SQLDataSource and other built-in server DataSource types can be used in standalone (eg command-line) Java applications, Quartz scheduled tasks, and other use cases that don't involve the HTTP lifecycle - see Standalone DataSource Usage.

          So it's very likely you don't need JPA at all, which would obviate the need to create beans, maintain a parallel configuration, etc.

          Comment


            #6
            Yea - everyone brings up SmartClient / SmartGWT because of the robust UI / widget library it has. I actually think the whole DSRequest / DSResponse / DataSource paradigm is its strongest suit.

            Do these carefully - including object oriented design such as extending / overriding other datasources, throw the RESTHandler servlet on top of it and you can stand up a fully restful service layer for your entire org / app / datamodel in a fraction of the time and cost.

            So as much as I love the UI library, I love their SQLDatasource and RESTHandler even more.

            Comment

            Working...
            X