Announcement

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

    Logging database operations

    I am trying to log all writing-database operations: updates, inserts, delets, etc.
    How would it be the best possible way to do that?

    Intercept all datasources and write a DMI method? a more "general" way ?
    Is there a "recommended" way to do this?

    Using smartgwt 3.1p EE.

    #2
    The simplest thing is probably a custom DataSource that subclasses whatever built-in DataSource you're using, then overrides execute() to do logging, then call super. See the QuickStart Guide, Custom DataSources section for details.

    Comment


      #3
      Is it possible that one datasource subclasses more than one datasource? I use in my applications more than one datasource, so I would have to subclass them all to add this functionality?

      Comment


        #4
        No, Java doesn't allow multiple subclassing.

        It seems you'll probably have a maximum of two different subclasses to create, and they can call common code.

        Comment


          #5
          Why a maximum of two different subclasses?

          If I have 10 datasources, I would have to write 10 subclasses, or what do I understand wrong?

          Comment


            #6
            There are only a handful of framework DataSources - SQLDataSource, HibernateDataSource, etc.

            Whichever of these you are extending, make one subclass that contains your logging logic. Then have all your other custom DataSources use that class (serverConstructor attribute - see QuickStart), or extend from that class.

            Comment

            Working...
            X