Deleting old data

From: Pirola Davide (davide.pirol..atrix.it)
Date: Tue Jun 27 2006 - 05:43:55 EDT

  • Next message: Robert Zeigler: "Re: various exceptions with cayenne 1.2RC2"

    Hi all,
    i have a problem with the "DELETE" operation.
    I have "TimerTask" that every 5 minutes load data from an Oracle Database and insert them into HsqlDb (locale to the application).
    So every 5 minutes my table on HSQLDB receive some "INSERT" commands.
    I do this with this peace of code:

    for (....all my objects)
    {
            datacontext.registerNewObject(myobject)
            datacontext.commitChanges()
    }

    But, first of all, i need to "DELETE" data that are older than 60 minutes.
    So i try to delete these data in this way:

    1) i execute a SELECT query on the table (HSQLDB)getting all record that are older than 60 minutes.

    2) for every object retrived, i execute "datacontext.delete(myobject)"

    3) at the end i call "datacontext.commitChanges()".

    I expect to see some "DELETE" query over my HSQLDB... but nothing appen :-S
    So no data are deleted... and my database grow :(

    There is another way for doing this task... execute directly the delete query:
     "DELETE FROM mytable WHERE DATEDIFF('mi',INSERT_DATE, NOW()) > 60 "

    but..in this way.. the data in the table are deleted, but cayenne takes in the Heap (Old Gen) the reference of the old objects... so the garbage collector can't remove them from memory.(memory leak)

    So question is... which is the right way to delete data in a table using cayenne?

    Thanks,
    Davide



    This archive was generated by hypermail 2.0.0 : Tue Jun 27 2006 - 08:40:00 EDT