Transaction confirmation.

From: Vassilis Raxenidis (raxe..orthnet.gr)
Date: Fri Feb 06 2004 - 04:06:35 EST

  • Next message: Nenko Ivanov: "Newbie, retrieving list from specific class DataObjects"

    Hi,

    I' m a new user of Cayenne and I would like to ask a question concerning the
    confirmation of the transactions committed.

    Suppose for example an application that forwards messages stored into a
    database table. This application periodically loads any new message from the
    corresponding table, deletes the message from db and processes (forward) the
    message.

    The above process could be implemented in general by the following code:

    ResultIterator res = dataContext.performIteratedQuery(Query);

    while (res.hasNextRow()) {

                Map row = res.nextDataRow();

    object = dataContext.objectFromDataRow(objectname, row);

    //keep data in memory and then delete data from db

    //so that they not appear on the next db polling.

    dataContext.deleteObject(object);

    dataContext.commitChanges();

    //process the loaded object

    }

    My problem is that I want to be sure that the object is deleted. The reason
    for this is that the object must be processed if and only if it is
    successfully deleted from db. If for any reason the message is not deleted
    then it will not be processed and should remain in db until the next
    polling. This technique will avoid the need for checking if a new loaded
    object is an undeleted one and processed. Of course if no exception is
    thrown on commitChanges() call, it is safe to consider the object as
    deleted. But what happens if an exception is thrown when the commitChanges()
    is called. In such a case how can I be sure whether the object is deleted or
    not?

    Vassilis Raxenidis



    This archive was generated by hypermail 2.0.0 : Fri Feb 06 2004 - 04:06:37 EST