4 Replies Latest reply on Apr 7, 2009 4:53 AM by jorgemoralespou_2

    How to subclass JDBCCacheLoader

    jorgemoralespou_2

      Hi,
      We have a requisite to remove old data from datastore that has not been used for a long time, or for example, as a ersult of an scheduled task, for example, every midnight, or data that is in DB for longer than 6 hours.
      We are trying to subclass JDBCCacheLoader, to add a timestamp column, so we can remove old data from DB, but this class is not meant for subclassing, so we have to almost rewrite it completely, and aldo configs, and so on.
      In JBC 1.4 this process was a lot easier.
      Would it be possible to design cache loaders to be subclassable?

        • 1. Re: How to subclass JDBCCacheLoader
          manik

          A reasonable request. Something for us to think about moving fwd.

          • 2. Re: How to subclass JDBCCacheLoader
            jorgemoralespou_2
            • 3. Re: How to subclass JDBCCacheLoader
              genman

              One thing that came to mind was to add a general configuration set that would allow Node key values to be mapped into specific table columns. (Sort of a poor man's JPA.) Data would be therefore stored in a way that was easily accessible and managed by your DBA.

              But really the only practical use I considered would be for managing timestamps of data.

              But instead of writing code, one thing you could consider is simply adding a update timestamp column to the cache loader's table, which is populated through a trigger. Then a background process run by your DBA could cull the data as necessary.

              • 4. Re: How to subclass JDBCCacheLoader
                jorgemoralespou_2

                 

                "genman" wrote:

                But instead of writing code, one thing you could consider is simply adding a update timestamp column to the cache loader's table, which is populated through a trigger. Then a background process run by your DBA could cull the data as necessary.


                With the fixes Manick have done, now I can subclass JDBCCacheloader, and introduced a timestamp in:

                TimestampedJDBCCacheLoader.populatePreparedStatementForInsert

                TimestampedJDBCCacheLoader.updateNode


                and also:
                TimestampedJDBCCacheLoaderConfig.constructCreateTableDDL

                TimestampedJDBCCacheLoaderConfig.constructUpdateNodeSql

                TimestampedJDBCCacheLoaderConfig.constructInsertNodeSql


                This modifications add a timestamp column, and set timestamp value in every insert/update in the database and no need to cal the DBA guy to insert a trigger.

                We are developing a product, we are a group of 5 developers, with different databases (mysql, oracle) as target for our application, so this solution seems easier for us. No need to know on target database peculiarities.

                Probably to do a more complex mapping as you suggest, needs more programming on the JDBCCacheLoader subclass, but sometimes can be useful, as per when the client you deploy the app in, wants, no matter how, to have the dba guy tunning the DB, and wanting to know what goes into the DB. You know they aren`t very eager to rely on blobs.